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

Avoid identical computation in self tanimoto similarity #117

Open
JochenSiegWork opened this issue Jan 31, 2025 · 0 comments
Open

Avoid identical computation in self tanimoto similarity #117

JochenSiegWork opened this issue Jan 31, 2025 · 0 comments
Assignees
Labels
type: maintenance Improvement of code or keeping the code up to date

Comments

@JochenSiegWork
Copy link
Collaborator

The ´self_tanimoto_similarity´ function equates matrix_a to itself, and then it calls the tanimoto_similarity_sparse. Calculating norm_2 is repeated in this case which is unnecessarily costly for large arrays. See

norm_2 = np.array(matrix_b.multiply(matrix_b).sum(axis=1))

We can add a simple check for identity of the two matrices to avoid redundant computation.

Thanks to Afnan for bringing this to our attention!

@JochenSiegWork JochenSiegWork added the type: maintenance Improvement of code or keeping the code up to date label Jan 31, 2025
@JochenSiegWork JochenSiegWork self-assigned this Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: maintenance Improvement of code or keeping the code up to date
Projects
None yet
Development

No branches or pull requests

1 participant