diff --git a/src/svsbench/search.py b/src/svsbench/search.py index 7290471..384864c 100644 --- a/src/svsbench/search.py +++ b/src/svsbench/search.py @@ -166,7 +166,7 @@ def search( search_buffer_optimization: svs.VamanaSearchBufferOptimization = svs.VamanaSearchBufferOptimization.All, shuffle: bool = False, seed: int = 42, -) -> tuple[np.ndarray, np.ndarray, float]: +) -> tuple[list[np.ndarray], list[np.ndarray], list[float]]: logger.info({"search_args": locals()}) logger.info(utils.read_system_config()) if query_path is None: @@ -221,6 +221,9 @@ def search( permutation = np.random.default_rng(seed).permutation(index.size) ground_truth = np.argsort(permutation)[ground_truth].astype(dtype=dtype, casting="same_value") + results_all = [] + distances_all = [] + recalls_all = [] for batch_size_idx, batch_size in enumerate(batch_sizes): index.num_threads = min(max_threads, batch_size) if search_window_sizes is None: @@ -345,7 +348,10 @@ def search( }, } ) - return results, distances, recall + results_all.append(results) + distances_all.append(distances) + recalls_all.append(recall) + return results_all, distances_all, recalls_all def main(argv: str | None = None) -> None: diff --git a/tests/test_search.py b/tests/test_search.py index 65dbb2f..cdbc80e 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -32,7 +32,7 @@ def test_search( pytest.skip("Not supported") if svs_type != index_svs_type: compress = True - _, _, recall = search( + _, _, recalls = search( idx_dir=index_dir, svs_type=svs_type, distance=svs.DistanceType.L2, @@ -43,7 +43,7 @@ def test_search( load_from_static=not index_dynamic, ) # Search parameters are calibrated to recall 0.9 - assert recall > 0.8 + assert recalls[0] > 0.8 def test_search_with_separate_data_dir(): @@ -71,7 +71,7 @@ def test_search_with_shuffle(tmp_vecs, query_path, tmp_path): seed=seed, ) idx_dir = save(build_result[0], tmp_path) - _, _, recall = search( + _, _, recalls = search( idx_dir=idx_dir, svs_type=svs_type, distance=distance, @@ -81,4 +81,4 @@ def test_search_with_shuffle(tmp_vecs, query_path, tmp_path): seed=seed, ) # Search parameters are calibrated to recall 0.9 - assert recall > 0.8 + assert recalls[0] > 0.8