MCPcopy Create free account
hub / github.com/MinishLab/vicinity / test_vicinity_delete

Function test_vicinity_delete

tests/test_vicinity.py:104–131  ·  view source on GitHub ↗

Test Vicinity.delete method by verifying that the vector for a deleted item is not returned in subsequent queries. :param vicinity_instance: A Vicinity instance. :param items: List of item names. :param vectors: Array of vectors corresponding to items.

(vicinity_instance: Vicinity, items: list[str], vectors: np.ndarray)

Source from the content-addressed store, hash-verified

102
103
104def test_vicinity_delete(vicinity_instance: Vicinity, items: list[str], vectors: np.ndarray) -> None:
105 """
106 Test Vicinity.delete method by verifying that the vector for a deleted item is not returned in subsequent queries.
107
108 :param vicinity_instance: A Vicinity instance.
109 :param items: List of item names.
110 :param vectors: Array of vectors corresponding to items.
111 """
112 if vicinity_instance.backend.backend_type != Backend.BASIC:
113 # Skip delete for non-basic backends
114 return
115
116 # Get the vector corresponding to "item2"
117 item2_index = items.index("item2")
118 item2_vector = vectors[item2_index]
119
120 # Delete "item2" from the Vicinity instance
121 vicinity_instance.delete(["item2"])
122
123 # Ensure "item2" is no longer in the items list
124 assert "item2" not in vicinity_instance.items
125
126 # Query using the vector of "item2"
127 results = vicinity_instance.query(item2_vector, k=5)
128 returned_items = [item for item, _ in results[0]]
129
130 # Check that "item2" is not in the results
131 assert "item2" not in returned_items
132
133
134def test_vicinity_save_and_load(tmp_path: Path, vicinity_instance: Vicinity) -> None:

Callers

nothing calls this directly

Calls 2

deleteMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…