(mockfs)
| 178 | |
| 179 | @require_faiss |
| 180 | def 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 |
nothing calls this directly
no test coverage detected