Repository navigation
test(python): migrate index count tests to the 0.8 API - #226
Merged
gouyt13 merged 2 commits intoNov 11, 2026
Merged
Conversation
gouyt13
reviewed
Nov 11, 2026
gouyt13
left a comment
Member
There was a problem hiding this comment.
Thanks, this migration looks correct and keeps what the test checks. I ran the file with -W error::DeprecationWarning against a build of main (8 passed, stable over repeated runs), and scripts/check-python.sh passes.
Two small follow-ups, as suggestions you can commit directly:
- The two later
add()calls used the default thread count before. The rule in #214 to passnum_threads=1applies only wherebuild()is replaced, sincebuild()defaulted to one thread, so these two calls can keep the default. - Set the capacity after the first
add()in each branch instead of withkind != "hnsw". This matches how the laterif kind == "ivf"updates read.
The tests still pass with all three suggestions applied.
Comment on lines
+45
to
+51
| if kind == "symqg": | ||
| index.build(data[:count], ef_construction=40, num_threads=1) | ||
| capacity = count | ||
| index.add(data[:count], num_threads=1) | ||
| else: | ||
| index.build(data[:count], centroid, assignments[:count]) | ||
| index.set_centroids(centroid) | ||
| index.add(data[:count], cluster_ids=assignments[:count], num_threads=1) | ||
| if kind != "hnsw": | ||
| capacity = count |
Member
There was a problem hiding this comment.
Suggested change
| if kind == "symqg": | |
| index.build(data[:count], ef_construction=40, num_threads=1) | |
| capacity = count | |
| index.add(data[:count], num_threads=1) | |
| else: | |
| index.build(data[:count], centroid, assignments[:count]) | |
| index.set_centroids(centroid) | |
| index.add(data[:count], cluster_ids=assignments[:count], num_threads=1) | |
| if kind != "hnsw": | |
| capacity = count | |
| if kind == "symqg": | |
| index.add(data[:count], num_threads=1) | |
| capacity = count | |
| else: | |
| index.set_centroids(centroid) | |
| index.add(data[:count], cluster_ids=assignments[:count], num_threads=1) | |
| if kind == "ivf": | |
| capacity = count |
HNSW keeps the 64 slots from resize(64); IVF and SymphonyQG now hold exactly count.
| check_counts(index, capacity, count, count - 3) | ||
|
|
||
| ids = index.add(data[count : count + 3], assignments[:3]) | ||
| ids = index.add(data[count : count + 3], cluster_ids=assignments[:3], num_threads=1) |
Member
There was a problem hiding this comment.
Suggested change
| ids = index.add(data[count : count + 3], cluster_ids=assignments[:3], num_threads=1) | |
| ids = index.add(data[count : count + 3], cluster_ids=assignments[:3]) |
This call used the default thread count before; only replaced build() calls need num_threads=1.
|
|
||
| np.testing.assert_array_equal(index.add(data[-1:], assignments[:1]), [stored]) | ||
| np.testing.assert_array_equal( | ||
| index.add(data[-1:], cluster_ids=assignments[:1], num_threads=1), [stored] |
Member
There was a problem hiding this comment.
Suggested change
| index.add(data[-1:], cluster_ids=assignments[:1], num_threads=1), [stored] | |
| index.add(data[-1:], cluster_ids=assignments[:1]), [stored] |
Same here.
Keep default threading for the two later add calls and place capacity updates in their respective initialization branches.
This was referenced Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The eight lifecycle-count cases in
tests/python/test_index_counts.pycurrently fail whenDeprecationWarningis treated as an error. Migrate their setup and insertion calls to the 0.8 API so they can continue checking capacity, stored records, live points, removal, and persistence after the 0.7 call forms are removed.resize(64)and configure the single supplied centroid explicitly.build()withset_centroids()and keyword-basedadd(), keeping one worker thread.nbits=32for raw vectors, moveef_construction=40to construction, and build throughadd().Related to #214. This PR covers only
test_index_counts.py; the tracking issue still has other files to migrate.Testing
Validation on Ubuntu under WSL2, Python 3.14.10, with a source build of this checkout and
RABITQ_ENABLE_NATIVE_OPTIMIZATION=OFF:-W error::DeprecationWarning.python -m pytest tests/python/test_index_counts.py -W error::DeprecationWarning -q— 8 passed, no warnings.python -m pytest tests/python --ignore=tests/python/test_compare_with_faiss.py --ignore=tests/python/test_cpp_clustering_examples.py --ignore=tests/python/test_benchmark_protocol.py --disable-warnings --tb=short -q.git show HEAD:scripts/check-python.sh | bashbecause the Windows checkout had CRLF line endings.git diff --check— passed.AI assistance was used to prepare the migration and run local validation.