Repository navigation
test(python): migrate the last seven test files off the 0.7 call forms - #230
Merged
Merged
Conversation
Migrate test_ivf, test_hnsw, test_symqg, test_input_boundaries, test_ivf_initializers, test_portable_indexes and test_import to the 0.8 API: constructors without max_elements, and set_centroids plus add in place of build. Calls that relied on build's single thread pass num_threads=1, and HNSW passes nbits and num_clusters explicitly. Tests of 0.7-only behavior move to test_compat_08.py, wrapped in quietly: build's row-count diagnostics, SymphonyQG rebuilds and build's default init, HNSW's rejected rebuild and zero capacity, and IVF's rebuild of a loaded index. test_invalid_quantization_bits_raises is deleted, because test_compat_08.py already covers it. Where 0.8 behaves differently, the expectations follow it: set_centroids and HNSW add report their own messages, an untrained IvfIndex trains on its first add unless cluster IDs are given, and SymphonyQG's access-guard check uses add, its only write. IvfIndex.set_centroids builds the HNSW routing graph with every CPU, so the 128-centroid routing test checks self-recall in aggregate. Every test file except the four exempt ones now passes with -W error::DeprecationWarning.
This was referenced Nov 13, 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.
Closes #214
This migrates the seven remaining files off the 0.7 call forms:
test_ivf.py,test_hnsw.py,test_symqg.py,test_input_boundaries.py,test_ivf_initializers.py,test_portable_indexes.pyandtest_import.py. #226 and #227 migrated the other eleven. Every test file except the four exempt ones (test_compat_08.py,test_txtai_compat.py,test_train_api.py,test_symqg_api.py) now passes with-W error::DeprecationWarning.Changes
max_elements. HNSW passesnbitsandnum_clustersexplicitly. Where a test needs room for more points, it callsresize, as inpartial_hnsw.buildbecomesset_centroidsplusadd:build's single thread passnum_threads=1.fast_quantizationcarry over.test_ivf.pyandtest_hnsw.pyeach gain a small_builthelper for the dozen or so cases that set centroids and add data.set_centroidsand HNSWaddreport their own messages for a wrong centroid shape or an out-of-range cluster ID.IvfIndextrains on its firstadd, so "add before training raises" now passescluster_ids, as the HNSW test already did.search_batch. The SymphonyQG validation test usessearch, sincesearch_batchis a deprecated alias.test_path_callback_runs_before_access_guard, the SymphonyQG case callsadd, its only write, inside the path callback. A free guard gives the "incremental addition" error; a held guard would giveIndex is busy.Moved to
test_compat_08.pyor deletedTests of behavior with no 0.8 form. Each moved test is wrapped in
quietly; #213 deletes that file.test_build_row_count_diagnosticstest_input_boundaries.pytest_failed_rebuild_preserves_indextest_symqg.pytest_successful_rebuild_replaces_indextest_symqg.pyinitofSymqgIndex.build(one assertion)test_symqg.pytest_invalid_quantization_bits_raisestest_symqg.pytest_symqg_mixed_or_invalid_old_formscovers ittest_rejected_rebuild_preserves_indextest_hnsw.pytest_zero_capacity_raisestest_hnsw.pytest_rebuild_matches_incremental_encoding_with_empty_clusterstest_ivf.pybuildhas no 0.8 form; C++IvfConstructionTestcovers the same encodingIVF HNSW routing threads
IvfIndex.set_centroidshas nonum_threadsand builds the HNSW routing graph with every CPU. The 0.7buildpassed its thread count through. Two tests are affected:test_hnsw_centroid_routing_roundtrip(128 centroids) checks every centroid's self-recall in aggregate, at least 97%, instead of four exact matches. A parallel hnswlib build may leave a centroid unreachable (Make graph-index tests independent of graph connectivity #216).test_hnsw_parallel_build_routes_and_reloads:threadsnow applies toaddand search only.A follow-up PR adds
num_threadstoIvfIndex.set_centroids. The C++ method already takes it. That PR also restores both tests.Checks
On Linux x86-64, Xeon Gold 6418H, GCC 14.3, Release, native optimization off; the package was built from
main.-W error::DeprecationWarning: 428 passed.check-python.shpasses.test_compat_08.pyin a loop: 208 runs, 0 failures. These runs include the graph builds that now use every CPU.