Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
refactor(indexer): remove unused code in leveldbindexer
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhxiao committed Sep 11, 2019
1 parent 453fe73 commit d007fd9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_annoyindexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np

from gnes.indexer.chunk.annoy import AnnoyIndexer
from gnes.indexer.chunk.numpy import NumpyIndexer


class TestAnnoyIndexer(unittest.TestCase):
Expand All @@ -27,3 +28,19 @@ def test_search(self):
a.close()
a.dump()
a.dump_yaml()

def test_numpy_indexer(self):
a = NumpyIndexer()
a.add(list(zip(list(range(10)), list(range(10)))), self.toy_data, [1.] * 10)
self.assertEqual(a.num_chunks, 10)
self.assertEqual(a.num_docs, 10)
top_1 = [i[0][0] for i in a.query(self.toy_data, top_k=1)]
self.assertEqual(top_1, list(range(10)))
a.close()
a.dump()
a.dump_yaml()
b = NumpyIndexer.load_yaml(a.yaml_full_path)
self.assertEqual(b.num_chunks, 10)
self.assertEqual(b.num_docs, 10)
top_1 = [i[0][0] for i in b.query(self.toy_data, top_k=1)]
self.assertEqual(top_1, list(range(10)))

0 comments on commit d007fd9

Please sign in to comment.