Skip to content

Commit d47bb75

Browse files
committed
linting
1 parent 25bf009 commit d47bb75

File tree

6 files changed

+20
-10
lines changed

6 files changed

+20
-10
lines changed

ms2query/data_processing/fingerprint_computation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import numpy as np
21
import numba
3-
from numba import types, typed
2+
import numpy as np
3+
from numba import typed, types
44
from rdkit import Chem
55
from tqdm import tqdm
66

ms2query/database/ann_vector_index.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,15 @@ def _build_where_clause(self, where_sql: Optional[str]) -> str:
297297
return f"WHERE {where_sql}"
298298

299299
# ---------- querying ----------
300-
def query(self, vector: np.ndarray, k: int = 10, ef: Optional[int] = None, assume_normalized: Optional[bool] = None):
300+
def query(
301+
self,
302+
vector: np.ndarray,
303+
k: int = 10,
304+
ef: Optional[int] = None,
305+
assume_normalized: Optional[bool] = None
306+
) -> List[Tuple[str, float]]:
307+
"""Query the index with a single vector.
308+
"""
301309
if self._index is None:
302310
raise RuntimeError("Index not built or loaded.")
303311
v = np.asarray(vector, dtype=np.float32).reshape(1, -1)
@@ -322,6 +330,8 @@ def query(self, vector: np.ndarray, k: int = 10, ef: Optional[int] = None, assum
322330

323331
# ---------- persistence ----------
324332
def save_index(self, path_prefix: str) -> None:
333+
"""Save index to files with given prefix.
334+
"""
325335
if self._index is None or self._ids is None:
326336
raise RuntimeError("Index not built or loaded.")
327337
meta_path = f"{path_prefix}.meta.json"
@@ -335,6 +345,8 @@ def save_index(self, path_prefix: str) -> None:
335345
json.dump(meta, f)
336346

337347
def load_index(self, path_prefix: str) -> None:
348+
"""Load index from files with given prefix.
349+
"""
338350
meta_path = f"{path_prefix}.meta.json"
339351
ids_path = f"{path_prefix}.ids.npy"
340352
hnsw_path = str(path_prefix) #f"{path_prefix}.nmslib"

ms2query/database/spectral_database.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,9 @@ def get_embeddings(
318318
cur.execute(f"SELECT spec_id, d, vec FROM {embeddings_table} ORDER BY spec_id ASC;")
319319
else:
320320
ph = ",".join("?" for _ in ids)
321-
cur.execute(f"SELECT spec_id, d, vec FROM {embeddings_table} WHERE spec_id IN ({ph}) ORDER BY spec_id ASC;", ids)
321+
cur.execute(
322+
f"SELECT spec_id, d, vec FROM {embeddings_table} WHERE spec_id IN ({ph}) ORDER BY spec_id ASC;",
323+
ids)
322324

323325
sids: List[str] = []
324326
vecs: List[np.ndarray] = []

ms2query/library_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from tqdm import tqdm
99
from ms2query import MS2QueryDatabase, MS2QueryLibrary
1010
from ms2query.data_processing.merging_utils import cluster_block, get_merged_spectra
11-
from ms2query.database import EmbeddingIndex, FingerprintSparseIndex
11+
from ms2query.database import EmbeddingIndex
1212
from ms2query.database.spectra_merging import _split_by_mode_charge
1313

1414

tests/test_ann_vector_index.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ def test_save_and_load_roundtrip_dense(tmp_path):
6666
def test_build_index_from_sqlite_streams_and_orders(batch_rows):
6767
conn = sqlite3.connect(":memory:")
6868
conn.execute("CREATE TABLE embeddings(spec_id TEXT, vec BLOB, d INTEGER)")
69-
# Two 3D vectors; deliberately unsorted insertion order
70-
v1 = np.array([1.0, 0.0, 0.0], np.float32)
71-
v2 = np.array([1.0, 1.0, 0.0], np.float32)
69+
# Add 3 vectors of dim 3
7270
conn.executemany( "INSERT INTO embeddings(spec_id, vec, d) VALUES (?,?,?)",
7371
[
7472
("id_1", np.array([1.0, 0.0, 0.0], np.float32).tobytes(), 3),

tests/test_compound_database.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import sqlite3
33
from pathlib import Path
44
import numpy as np
5-
import pandas as pd
6-
import pytest
75
from ms2query.data_processing import compute_morgan_fingerprints
86
from ms2query.database.compound_database import (
97
CompoundDatabase,

0 commit comments

Comments
 (0)