Skip to content

Commit

Permalink
Add unit test to test Annoy Indexing of KeyedVectors
Browse files Browse the repository at this point in the history
  • Loading branch information
pengowray committed May 17, 2017
1 parent 0dcb44e commit 34839a6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions gensim/test/test_similarities.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,19 @@ def testFastText(self):
self.assertIndexSaved(index)
self.assertLoadedIndexEqual(index, model)

def testAnnoyIndexingOfKeyedVectors(self):
ft_home = os.environ.get('FT_HOME', None)
ft_path = os.path.join(ft_home, 'fasttext') if ft_home else None
if not ft_path:
return
keyVectors_file = datapath('lee_fasttext.vec')
model = KeyedVectors.load_word2vec_format(keyVectors_file)
index = AnnoyIndexer(model, 10)

self.assertEqual(index.num_trees, 10)
self.assertVectorIsSimilarToItself(model, index)
self.assertApproxNeighborsMatchExact(model, index)

def testLoadMissingRaisesError(self):
from gensim.similarities.index import AnnoyIndexer
test_index = AnnoyIndexer()
Expand Down

0 comments on commit 34839a6

Please sign in to comment.