Skip to content

Commit

Permalink
ekv -> kv
Browse files Browse the repository at this point in the history
  • Loading branch information
menshikh-iv committed Mar 1, 2020
1 parent 9c1f0f2 commit 38daff5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions gensim/test/test_keyedvectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import numpy as np

from gensim.corpora import Dictionary
from gensim.models.keyedvectors import KeyedVectors as EuclideanKeyedVectors, WordEmbeddingSimilarityIndex, \
from gensim.models.keyedvectors import KeyedVectors, WordEmbeddingSimilarityIndex, \
FastTextKeyedVectors
from gensim.test.utils import datapath

Expand All @@ -27,7 +27,7 @@

class TestWordEmbeddingSimilarityIndex(unittest.TestCase):
def setUp(self):
self.vectors = EuclideanKeyedVectors.load_word2vec_format(
self.vectors = KeyedVectors.load_word2vec_format(
datapath('euclidean_vectors.bin'), binary=True, datatype=np.float64)

def test_most_similar(self):
Expand Down Expand Up @@ -70,9 +70,9 @@ def test_most_similar(self):
self.assertTrue(np.allclose(first_similarities**2.0, second_similarities))


class TestEuclideanKeyedVectors(unittest.TestCase):
class TestKeyedVectors(unittest.TestCase):
def setUp(self):
self.vectors = EuclideanKeyedVectors.load_word2vec_format(
self.vectors = KeyedVectors.load_word2vec_format(
datapath('euclidean_vectors.bin'), binary=True, datatype=np.float64)

def test_similarity_matrix(self):
Expand Down Expand Up @@ -227,7 +227,7 @@ def test_add_single(self):
self.assertTrue(np.allclose(self.vectors[ent], vector))

# Test `add` on empty kv.
kv = EuclideanKeyedVectors(self.vectors.vector_size)
kv = KeyedVectors(self.vectors.vector_size)
for ent, vector in zip(entities, vectors):
kv.add(ent, vector)

Expand All @@ -248,15 +248,15 @@ def test_add_multiple(self):
self.assertTrue(np.allclose(self.vectors[ent], vector))

# Test `add` on empty kv.
kv = EuclideanKeyedVectors(self.vectors.vector_size)
kv = KeyedVectors(self.vectors.vector_size)
kv[entities] = vectors
self.assertEqual(len(kv.vocab), len(entities))

for ent, vector in zip(entities, vectors):
self.assertTrue(np.allclose(kv[ent], vector))

def test_add_type(self):
kv = EuclideanKeyedVectors(2)
kv = KeyedVectors(2)
words, vectors = ["a"], np.array([1., 1.], dtype=np.float32).reshape(1, -1)

assert kv.vectors.dtype == np.float64 # default dtype of empty KV
Expand Down Expand Up @@ -296,7 +296,7 @@ def test_set_item(self):
self.assertTrue(np.allclose(self.vectors[ent], vector))

def test_ft_kv_backward_compat_w_360(self):
kv = EuclideanKeyedVectors.load(datapath("ft_kv_3.6.0.model.gz"))
kv = KeyedVectors.load(datapath("ft_kv_3.6.0.model.gz"))
ft_kv = FastTextKeyedVectors.load(datapath("ft_kv_3.6.0.model.gz"))

expected = ['trees', 'survey', 'system', 'graph', 'interface']
Expand Down

0 comments on commit 38daff5

Please sign in to comment.