Skip to content

Commit

Permalink
Adding a test case
Browse files Browse the repository at this point in the history
  • Loading branch information
searchivairus committed Jan 7, 2018
1 parent aa6816c commit b47b22a
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions python_bindings/tests/bindings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,25 @@ def _get_index(self, space='cosinesimil'):
return nmslib.init(method='sw-graph', space=space)

def testReloadIndex(self):
# Throws an error - pEntryPoint isn't set on loadIndex
# RuntimeError: Check failed: Bug: there is not entry point set!
return NotImplemented
np.random.seed(23)
data = np.random.randn(1000, 10).astype(np.float32)

original = self._get_index()
original.addDataPointBatch(data)
original.createIndex()

# test out saving/reloading index
with tempfile.NamedTemporaryFile() as tmp:
original.saveIndex(tmp.name + ".index")

reloaded = self._get_index()
reloaded.addDataPointBatch(data)
reloaded.loadIndex(tmp.name + ".index")

original_results = original.knnQuery(data[0])
reloaded_results = reloaded.knnQuery(data[0])
npt.assert_allclose(original_results,
reloaded_results)


class BallTreeTestCase(unittest.TestCase, DenseIndexTestMixin):
Expand Down

0 comments on commit b47b22a

Please sign in to comment.