diff --git a/tests/conftest.py b/tests/conftest.py index 5e8780f..fdb0883 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -10,10 +10,10 @@ # Define supported FAISS index types FAISS_INDEX_TYPES = [ - "flat", + # "flat", # "ivf", - # "hnsw", - # "lsh", + "hnsw", + "lsh", # "scalar", # "pq", # "ivf_scalar", @@ -42,11 +42,14 @@ def query_vector() -> np.ndarray: BACKEND_PARAMS = [(Backend.FAISS, index_type) for index_type in FAISS_INDEX_TYPES] + [ (Backend.BASIC, None), - (Backend.HNSW, None), - (Backend.ANNOY, None), - (Backend.PYNNDESCENT, None), + # (Backend.HNSW, None), + # (Backend.ANNOY, None), + # (Backend.PYNNDESCENT, None), ] +# Create human-readable ids for each backend type +BACKEND_IDS = [f"{backend.name}-{index_type}" if index_type else backend.name for backend, index_type in BACKEND_PARAMS] + @pytest.fixture(params=BACKEND_PARAMS) def backend_type(request: pytest.FixtureRequest) -> Backend: @@ -54,14 +57,14 @@ def backend_type(request: pytest.FixtureRequest) -> Backend: return request.param -@pytest.fixture(params=BACKEND_PARAMS) +@pytest.fixture(params=BACKEND_PARAMS, ids=BACKEND_IDS) def vicinity_instance(request: pytest.FixtureRequest, items: list[str], vectors: np.ndarray) -> Vicinity: """Fixture providing a Vicinity instance for each backend type.""" backend_type, index_type = request.param # Handle FAISS backend with specific FAISS index types if backend_type == Backend.FAISS: return Vicinity.from_vectors_and_items( - vectors, items, backend_type=backend_type, index_type=index_type, nlist=4 + vectors, items, backend_type=backend_type, index_type=index_type, nlist=4, nbits=32 ) # Handle non-FAISS backends without passing `index_type` diff --git a/tests/test_vicinity.py b/tests/test_vicinity.py index 7e7f758..5a59581 100644 --- a/tests/test_vicinity.py +++ b/tests/test_vicinity.py @@ -39,7 +39,7 @@ def test_vicinity_from_vectors_and_items( :param items: A list of item names. :param vectors: An array of vectors. """ - backend: Backend = backend_type[0] + backend = backend_type[0] vicinity = Vicinity.from_vectors_and_items(vectors, items, backend_type=backend) assert len(vicinity) == len(items) @@ -104,11 +104,8 @@ def test_vicinity_delete(vicinity_instance: Vicinity, items: list[str], vectors: # Don't test delete for Annoy and Pynndescent backend return - if vicinity_instance.backend.backend_type == Backend.FAISS and vicinity_instance.backend.arguments.index_type in { - "pq", - "scalar", - "ivfpq", - "ivfpqr", + elif vicinity_instance.backend.backend_type == Backend.FAISS and vicinity_instance.backend.arguments.index_type in { + "hnsw" }: # Skip delete test for FAISS index types that do not support deletion return