Skip to content

Commit b773f33

Browse files
committed
update to new helper
1 parent ec610b1 commit b773f33

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

ms2query/database/ann_index.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def build_index(self, *, index_path: Optional[str] = None) -> faiss.Index:
174174
if not first:
175175
raise ValueError("No embeddings present in 'merged_embeddings'.")
176176
first_id, first_blob = first
177-
first_vec = blob_to_ndarray(first_blob).astype(np.float32, copy=False)
177+
first_vec = blob_to_array(first_blob, np.float32, copy=False)
178178
d = int(first_vec.shape[-1])
179179

180180
metric = faiss.METRIC_INNER_PRODUCT if self.faiss_metric.lower() == "ip" else faiss.METRIC_L2
@@ -198,7 +198,7 @@ def build_index(self, *, index_path: Optional[str] = None) -> faiss.Index:
198198
break
199199
for mid, blob in rows:
200200
ids_buf.append(mid)
201-
vec_buf.append(blob_to_ndarray(blob))
201+
vec_buf.append(blob_to_array(blob, np.float32, copy=False))
202202
if ids_buf:
203203
Xb = np.vstack(vec_buf).astype(np.float32, copy=False)
204204
if self.faiss_metric.lower() == "ip" and self.normalize_embeddings:
@@ -258,8 +258,8 @@ def _fetch_merged_rows(
258258
"source_spec_ids": json.loads(source_spec_ids) if source_spec_ids else [],
259259
}
260260
if include_peaks:
261-
row["mz"] = blob_to_ndarray(mz_blob).astype(np.float32, copy=False)
262-
row["intensities"] = blob_to_ndarray(intens_blob).astype(np.float32, copy=False)
261+
row["mz"] = blob_to_array(mz_blob, np.float32, copy=False)
262+
row["intensities"] = blob_to_array(intens_blob, np.float32, copy=False)
263263
out[mid] = row
264264
return out
265265

@@ -392,7 +392,7 @@ def get_embeddings(
392392
vecs = []
393393
for mid, blob in cur:
394394
mids.append(int(mid))
395-
vecs.append(blob_to_ndarray(blob).astype(np.float32, copy=False))
395+
vecs.append(blob_to_array(blob, np.float32, copy=False))
396396
if not vecs:
397397
return np.empty((0,), dtype=np.int64), np.empty((0, 0), dtype=np.float32)
398398

0 commit comments

Comments
 (0)