Support similar and dissimilar threshold searches
This commit is contained in:
@@ -53,3 +53,11 @@ def test_graph_is_block_size_independent_and_deterministic(
|
||||
write_graph_edges(first_path, first.edges)
|
||||
write_graph_edges(second_path, repeated.edges)
|
||||
assert first_path.read_bytes() == second_path.read_bytes()
|
||||
|
||||
|
||||
def test_graph_supports_less_than_threshold_direction(small_dataset: Path) -> None:
|
||||
result = build_similarity_graph(
|
||||
small_dataset, threshold=0.15, block_size=2, threshold_direction="less"
|
||||
)
|
||||
|
||||
assert all(edge.similarity <= 0.15 for edge in result.edges)
|
||||
|
||||
@@ -37,3 +37,22 @@ def test_search_matches_full_sorting_and_skips_query_and_invalid(
|
||||
assert "DUPLICATE" not in {match.molecule_id for match in result.matches}
|
||||
assert result.stats.invalid == 1
|
||||
assert result.stats.valid == 5
|
||||
|
||||
|
||||
def test_search_can_rank_and_filter_least_similar_molecules(
|
||||
small_dataset: Path,
|
||||
) -> None:
|
||||
query = find_molecule_by_id(small_dataset, "QUERY")
|
||||
result = search_similar(
|
||||
small_dataset,
|
||||
query,
|
||||
top_k=20,
|
||||
threshold=0.2,
|
||||
threshold_direction="less",
|
||||
)
|
||||
|
||||
assert result.matches
|
||||
assert all(match.similarity <= 0.2 for match in result.matches)
|
||||
assert result.matches == sorted(
|
||||
result.matches, key=lambda match: match.sort_key("less")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user