mirror of https://github.com/explosion/spaCy.git
Raise error for inplace resize with new vector dim (#5228)
Raise an error if there is an attempt to resize the vectors in place with a different vector dimension.
This commit is contained in:
parent
0b76212831
commit
d107afcffb
|
@ -552,6 +552,9 @@ class Errors(object):
|
|||
E191 = ("Invalid head: the head token must be from the same doc as the "
|
||||
"token itself.")
|
||||
E192 = ("Unable to resize vectors in place with cupy.")
|
||||
E193 = ("Unable to resize vectors in place if the resized vector dimension "
|
||||
"({new_dim}) is not the same as the current vector dimension "
|
||||
"({curr_dim}).")
|
||||
|
||||
|
||||
@add_codes
|
||||
|
|
|
@ -200,6 +200,8 @@ cdef class Vectors:
|
|||
"""
|
||||
xp = get_array_module(self.data)
|
||||
if inplace:
|
||||
if shape[1] != self.data.shape[1]:
|
||||
raise ValueError(Errors.E193.format(new_dim=shape[1], curr_dim=self.data.shape[1]))
|
||||
if xp == numpy:
|
||||
self.data.resize(shape, refcheck=False)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue