-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
Fix bug in add_k_nn_edges
and add minor extension
#229
Conversation
`kneighbors_graph(X=dist_mat, ...)` is wrong since `X` may not be a distance matrix. This leads to wrong results which may be similar to correct ones.
Thanks for this @anton-bushuiev. Good spot! LGTM! Would you be able to add a couple tests? |
Yeah, I'll add them tomorrow. |
Kudos, SonarCloud Quality Gate passed! |
Codecov ReportBase: 40.27% // Head: 47.86% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #229 +/- ##
==========================================
+ Coverage 40.27% 47.86% +7.59%
==========================================
Files 48 85 +37
Lines 2811 5398 +2587
==========================================
+ Hits 1132 2584 +1452
- Misses 1679 2814 +1135
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Thanks for the contribution @anton-bushuiev! |
Reference Issues/PRs
No related issues/PRs
What does this implement/fix? Explain your changes
This pull request fixes a bug in
add_k_nn_edges
. Currenly,kneighbors_graph(X=dist_mat, ...)
leads to wrong results which may seem correct. According to scikit-learn docs, it does not supportX
to be a distance matrix.Secondly, this PR adds
filter_distmat
to generalise self-loops filtering. It adds the functionality to filter inter- or intra- connections between nodes of a single or multiple chains. It may be useful to incorporate it into other functions to add edges. By running the following code you will get the visualized graphs.What testing did you do to verify the changes in this PR?
Pull Request Checklist
./CHANGELOG.md
file (if applicable)./graphein/tests/*
directories (if applicable)./notebooks/
(if applicable)python -m py.test tests/
and make sure that all unit tests pass (for small modifications, it might be sufficient to only run the specific test file, e.g.,python -m py.test tests/protein/test_graphs.py
)black .
andisort .