Skip to content
Permalink
Browse files

refactor(indexer): remove unused code in leveldbindexer

  • Loading branch information...
hanxiao committed Sep 11, 2019
1 parent 453fe73 commit d007fd9bca7979b429ed96c6af73f699c3a1634b
Showing with 17 additions and 0 deletions.
  1. +17 −0 tests/test_annoyindexer.py
@@ -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):
@@ -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.
You can’t perform that action at this time.