Repository navigation
Description
Problem
0.8 introduced train / set_centroids / add, and the 0.7 forms (positional constructor
options, build, positional add options and others listed in #213) now raise
DeprecationWarning. 0.9 removes them. Many Python tests still use the 0.7 forms only for setup, so they
emit warnings now and will break in 0.9.
Task
Rewrite test setup that uses a deprecated form only to create or fill an index, using the
0.8 API.
This is a tracking issue: one PR per file (or a few small files) is ideal. The maintainers
are migrating the remaining files.
# 0.7 form
index.build(data, centroids, cluster_ids, num_threads=1)
# 0.8 form
index.set_centroids(centroids)
index.add(data, cluster_ids=cluster_ids, num_threads=1)The migration guide lists
every mapping, including HNSW and SymphonyQG.
Rules
- Keep each test's intent. A test of 0.7-only behavior with no 0.8 form (such as
build
replacing an index, or validation ofmax_elementsandquantization_bits) moves to
test_compat_08.py, which Remove the deprecated 0.7 Python call forms #213 deletes; wrap its deprecated calls in that file'squietly
orsingle_deprecation. Iftest_compat_08.pyalready covers it, delete it instead. Say
which in the PR. Known cases:test_hnsw.py::test_rejected_rebuild_preserves_indexand
test_zero_capacity_raises,test_symqg.py::test_failed_rebuild_preserves_index,
test_successful_rebuild_replaces_indexandtest_invalid_quantization_bits_raises, and
test_input_boundaries.py::test_build_row_count_diagnostics. - Do not change the existing tests in these files:
test_compat_08.py,test_txtai_compat.py,
test_train_api.py,test_symqg_api.py(they test compatibility or equivalence on purpose). - HNSW defaults differ: the 0.7 constructor used
nbits=8and the 0.8 one usesnbits=7, so
passnbits=explicitly.set_centroidsneedsHnswIndex(..., num_clusters=len(centroids)),
while the 0.7buildaccepted any number of centroids. max_elementsno longer comes from the constructor: a newIvfIndexstarts at 0 and grows
to the stored count, andHnswIndexgrows onadd. Update expectedmax_elementsvalues
and reprs; where a test needs a preallocated capacity, useHnswIndex.resize(n)(see test(python): migrate index count tests to the 0.8 API #226).- Pass
num_threadsexplicitly where the old call relied on its default:builddefaulted
to 1 thread, whileadddefaults to all CPUs. Tests that compare bytes or exact results
need the same thread count as before. - Run the edited file with
python -m pytest -W error::DeprecationWarning tests/python/<file>
to confirm no deprecated call remains; this also catches deprecated constructor forms
and properties that a search for.build(misses.
Files
Files with tests that fail under -W error::DeprecationWarning at v0.8.2, excluding the four
above.
-
test_ivf.py -
test_hnsw.py -
test_symqg.py -
test_input_boundaries.py -
test_ivf_initializers.py -
test_portable_indexes.py,test_import.py -
test_index_counts.py(test(python): migrate index count tests to the 0.8 API #226) -
test_build_cluster_ids.py,test_large_dimensions.py,test_array_alignment.py,
test_concurrent_indexes.py,test_thread_counts.py,test_persistence_paths.py,
test_index_repr.py,test_kmeans_sampling.py,test_remove_arrays.py,
test_quantization_factors.py(test(python): migrate ten test files off the 0.7 call forms #227)
The seven unchecked files are also changed by #222. #227 also applied the #216 fixes to the
graph cases of test_array_alignment.py and test_thread_counts.py.
Setup and checks: contribution guide, Python changes.
Activity
leo062644 commentedon Nov 10, 2026
I'd like to migrate tests/python/test_index_counts.py to the 0.8 API, preserving its capacity/live/stored-count checks and verifying it with DeprecationWarning treated as an error.
gouyt13 commentedon Nov 11, 2026
test_index_counts.pyis done in #226, thanks to leo062644.The maintainers will migrate the remaining files, so this issue is no longer open for new
claims. I updated the rules above with what the first migration showed:
test_compat_08.py, or is deleted where that filealready covers it, so every listed file can pass
-W error::DeprecationWarning. The knowncases are listed.
nbits=explicitly (8 by default in 0.7, 7 in 0.8), and passnum_clusters=len(centroids)to the constructor beforeset_centroids.max_elementsvalues and reprs may change, because the 0.8 constructors no longerset the capacity; this does not change what the test checks.
gouyt13 commentedon Nov 12, 2026
#227 migrates ten more files, now checked above. Its CI failed twice on graph builds that left one point unreachable, so it also applies the #216 fixes to the graph cases of
test_array_alignment.pyandtest_thread_counts.py. Seven files remain; #222 also changes them.