MCPcopy
hub / github.com/huggingface/datasets / test_serialization_fs

Function test_serialization_fs

tests/test_search.py:180–195  ·  view source on GitHub ↗
(mockfs)

Source from the content-addressed store, hash-verified

178
179@require_faiss
180def test_serialization_fs(mockfs):
181 import faiss
182
183 index = FaissIndex(metric_type=faiss.METRIC_INNER_PRODUCT)
184 index.add_vectors(np.eye(5, dtype=np.float32))
185
186 index_name = "index.faiss"
187 path = f"mock://{index_name}"
188 index.save(path, storage_options=mockfs.storage_options)
189 index = FaissIndex.load(path, storage_options=mockfs.storage_options)
190
191 query = np.zeros(5, dtype=np.float32)
192 query[1] = 1
193 scores, indices = index.search(query)
194 assert scores[0] > 0
195 assert indices[0] == 1
196
197
198@require_elasticsearch

Callers

nothing calls this directly

Calls 5

add_vectorsMethod · 0.95
saveMethod · 0.95
searchMethod · 0.95
FaissIndexClass · 0.90
loadMethod · 0.45

Tested by

no test coverage detected