Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Index.gather is not doing gather? #1263

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/sourmash/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ def gather(self, query, *args, **kwargs):

# actually do search!
results = []
query_mh = query.minhash
for ss in self.signatures():
cont = query.minhash.contained_by(ss.minhash, True)
cont = query_mh.contained_by(ss.minhash, True)
if cont and cont >= threshold:
results.append((cont, ss, self.filename))
query_mh.remove_many(ss.minhash.hashes)

results.sort(reverse=True, key=lambda x: (x[0], x[1].md5sum()))

Expand Down
4 changes: 1 addition & 3 deletions tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,9 @@ def test_linear_index_gather():
assert matches[0][1] == ss2

matches = lidx.gather(ss47)
assert len(matches) == 2
assert len(matches) == 1
assert matches[0][0] == 1.0
assert matches[0][1] == ss47
assert round(matches[1][0], 2) == 0.49
assert matches[1][1] == ss63
Comment on lines 134 to -139
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is a good example of the 'weird' behavior: if doing gather with ss47, it should match ss47 completely, and nothing will be left to match other sigs. But the test is asserting that there is a second match (ss63), at 0.49 containment. That's... not gather, that's a regular search using containment.



def test_linear_index_save():
Expand Down