Skip to content

Commit

Permalink
Adding test for IndexBinaryFlat.reconstruct_n() (#3310)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #3310

**Context**
[Issue 2751](#2751) is already fixed as class wrappers has replacement definition of reconstruct_n in handle_IndexBinary.

**In this diff**,
Writing test test_reconstruct for binary index to validate fix for above issue.

Reviewed By: junjieqi

Differential Revision: D55168600

fbshipit-source-id: b62dc5fa89d65b843c52faa7456f046142e34421
  • Loading branch information
kuarora authored and facebook-github-bot committed Mar 22, 2024
1 parent 798427c commit af5793c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_index_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ def test_range_search(self):
# nb tests is actually low...
self.assertTrue(nt1 > 19 and nt2 > 19)

def test_reconstruct(self):
index = faiss.IndexBinaryFlat(64)
input_vector = np.random.randint(0, 255, size=(10, index.code_size)).astype("uint8")
index.add(input_vector)

reconstructed_vector = index.reconstruct_n(0, 4)
assert reconstructed_vector.shape == (4, index.code_size)
assert np.all(input_vector[:4] == reconstructed_vector)


class TestBinaryIVF(unittest.TestCase):

Expand Down

0 comments on commit af5793c

Please sign in to comment.