Ensure doc.similarity returns a float (on develop) (#4969)

This commit is contained in:
Sofie Van Landeghem 2020-02-11 02:31:49 +01:00 committed by GitHub
parent cabd60fa1e
commit 781e95cf53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -391,7 +391,9 @@ cdef class Doc:
return 0.0
vector = self.vector
xp = get_array_module(vector)
return xp.dot(vector, other.vector) / (self.vector_norm * other.vector_norm)
result = xp.dot(vector, other.vector) / (self.vector_norm * other.vector_norm)
# ensure we get a scalar back (numpy does this automatically but cupy doesn't)
return result.item()
@property
def has_vector(self):