diff --git a/spacy/tests/util.py b/spacy/tests/util.py index 359767f1b..29f39ebf6 100644 --- a/spacy/tests/util.py +++ b/spacy/tests/util.py @@ -58,7 +58,7 @@ def get_doc( for annot in annotations: if annot: if annot is heads: - annot = numpy.array(heads).astype(numpy.uint64) + annot = numpy.array(heads, dtype=numpy.int32).astype(numpy.uint64) for i in range(len(words)): if attrs.ndim == 1: attrs[i] = annot[i] diff --git a/spacy/tokens/span.pyx b/spacy/tokens/span.pyx index a40347d23..5df8c823b 100644 --- a/spacy/tokens/span.pyx +++ b/spacy/tokens/span.pyx @@ -272,7 +272,7 @@ cdef class Span: for ancestor in ancestors: ancestor_i = ancestor.i - self.start if ancestor_i in range(length): - array[i, head_col] = numpy.array(ancestor_i - i).astype(numpy.uint64) + array[i, head_col] = numpy.int32(ancestor_i - i).astype(numpy.uint64) # if there is no appropriate ancestor, define a new artificial root value = array[i, head_col] @@ -280,7 +280,7 @@ cdef class Span: new_root = old_to_new_root.get(ancestor_i, None) if new_root is not None: # take the same artificial root as a previous token from the same sentence - array[i, head_col] = numpy.array(new_root - i).astype(numpy.uint64) + array[i, head_col] = numpy.int32(new_root - i).astype(numpy.uint64) else: # set this token as the new artificial root array[i, head_col] = 0