Skip to content

Commit

Permalink
fix/improve tests, #142
Browse files Browse the repository at this point in the history
  • Loading branch information
yurymalkov committed Aug 28, 2019
1 parent 018cc8d commit b3671c5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions python_bindings/tests/bindings_test_resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit b3671c5

Please sign in to comment.