Use the equality check

This commit is contained in:
Paul O'Leary McCann 2022-11-15 13:51:42 +09:00
parent 52bc927db9
commit 6f3210ebb9
2 changed files with 2 additions and 7 deletions

View File

@ -706,13 +706,7 @@ class Language:
# Check source type # Check source type
if not isinstance(source, Language): if not isinstance(source, Language):
raise ValueError(Errors.E945.format(name=source_name, source=type(source))) raise ValueError(Errors.E945.format(name=source_name, source=type(source)))
# Check vectors, with faster checks first if self.vocab.vectors != source.vocab.vectors:
if (
self.vocab.vectors.shape != source.vocab.vectors.shape
or self.vocab.vectors.key2row != source.vocab.vectors.key2row
or self.vocab.vectors.to_bytes(exclude=["strings"])
!= source.vocab.vectors.to_bytes(exclude=["strings"])
):
warnings.warn(Warnings.W113.format(name=source_name)) warnings.warn(Warnings.W113.format(name=source_name))
if source_name not in source.component_names: if source_name not in source.component_names:
raise KeyError( raise KeyError(

View File

@ -245,6 +245,7 @@ cdef class Vectors:
def __eq__(self, other): def __eq__(self, other):
# Check for equality, with faster checks first
return ( return (
self.shape == other.shape self.shape == other.shape
and self.key2row == other.key2row and self.key2row == other.key2row