From b3671c5edf0ac5d13a2309e86b4b48f8cee827f1 Mon Sep 17 00:00:00 2001 From: Yury Malkov Date: Wed, 28 Aug 2019 14:24:27 +0300 Subject: [PATCH] fix/improve tests, #142 --- python_bindings/tests/bindings_test_resize.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python_bindings/tests/bindings_test_resize.py b/python_bindings/tests/bindings_test_resize.py index 1803178d..5e798164 100644 --- a/python_bindings/tests/bindings_test_resize.py +++ b/python_bindings/tests/bindings_test_resize.py @@ -3,11 +3,11 @@ class RandomSelfTestCase(unittest.TestCase): def testRandomSelf(self): - + for idx in range(32): print("\n**** Index resize test ****\n") import hnswlib import numpy as np - + np.random.seed(idx) dim = 16 num_elements = 10000 @@ -29,9 +29,9 @@ def testRandomSelf(self): # Controlling the recall by setting ef: # higher ef leads to better accuracy, but slower search - p.set_ef(100) + p.set_ef(20) - p.set_num_threads(4) # by default using all available cores + p.set_num_threads(idx%8) # by default using all available cores # We split the data in two batches: data1 = data[:num_elements // 2] @@ -43,7 +43,7 @@ def testRandomSelf(self): # Query the elements for themselves and measure recall: labels, distances = p.knn_query(data1, k=1) - items=p.get_items(labels) + items=p.get_items(list(range(len(data1)))) # Check the recall: self.assertAlmostEqual(np.mean(labels.reshape(-1) == np.arange(len(data1))),1.0,3) @@ -62,7 +62,7 @@ def testRandomSelf(self): # Query the elements for themselves and measure recall: labels, distances = p.knn_query(data, k=1) - items=p.get_items(labels) + items=p.get_items(list(range(num_elements))) # Check the recall: self.assertAlmostEqual(np.mean(labels.reshape(-1) == np.arange(len(data))),1.0,3)