Skip to content

Commit aff2fd0

Browse files
committed
Add tests for top_k_tanimoto_scores
1 parent 2e643b4 commit aff2fd0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import numpy as np
2+
import pytest
3+
from ms2query.benchmarking.TopKTanimotoScores import TopKTanimotoScores
4+
from tests.helper_functions import make_test_fingerprints
5+
6+
7+
def test_methods_top_k_tanimoto_scores():
8+
scores = np.array([[1.0, 0.8], [0.9, 0.7], [0.8, 0.8]])
9+
inchikeys_in_top_2 = np.array([["A", "B"], ["B", "C"], ["C", "A"]])
10+
inchikeys = np.array(["A", "B", "C"])
11+
top_scores = TopKTanimotoScores(scores, inchikeys_in_top_2, inchikeys)
12+
13+
assert top_scores.select_top_k_inchikeys_and_scores("A") == {"A": 1.0, "B": 0.8}
14+
15+
assert top_scores.select_top_k_inchikeys("A") == ["A", "B"]
16+
17+
assert top_scores.select_average_score("A") == pytest.approx(0.9)
18+
19+
assert top_scores.get_all_average_tanimoto_scores() == {"A": 0.9, "B": 0.8, "C": 0.8}
20+
21+
22+
def test_calculate_from_fingerprints():
23+
fingerprints = make_test_fingerprints(20)
24+
TopKTanimotoScores.calculate_from_fingerprints(fingerprints, fingerprints, 10)

0 commit comments

Comments
 (0)