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 take into account mask in the ordering in grid_to_graph #18964
FIX take into account mask in the ordering in grid_to_graph #18964
Conversation
Apart from an additional test, LGTM
Please add an entry to the change log at doc/whats_new/v*.rst
. Like the other entries there, please reference this pull request with :pr:
and credit yourself (and other contributors if applicable) with :user:
.
Effectively, edges.ravel() (line 80 ) does not contain isolated vertices (vertex of an edge, that was not eliminated by the mask ) while np.where(mask.ravel()) include all vertices.
This is the consequence of the logical and in line 71 : if one of the 2 vertices of an edge is eliminated by the mask, then both are eliminated in the edges array (after line 73).
Shall I create a v1.0.rst ? that would be amazing ! |
You don't need to create the file, only to merge master into your branch (you will just have to remove |
Another related improvement could be a thresholding parameter in the case of an img that zeros out connections for edge weights below a certain value? |
Sorry, I don't understand the Changelog failure... Can anybody help ? |
@bthirion, do you mind synchronizing with upstream? My typo in the workflow has been fixed in main. This should fix the failure. Sorry for that and thanks for your collaboration. |
Working, thx ! |
Any second approval ? ;-) |
sklearn/feature_extraction/image.py
Outdated
order = np.searchsorted(np.unique(np.where(mask.ravel())), | ||
np.arange(maxval + 1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
order = np.searchsorted(np.unique(np.where(mask.ravel())), | |
np.arange(maxval + 1)) | |
order = np.searchsorted(np.flatnonzero(mask), np.arange(maxval + 1)) |
More readable and probably faster.
@bthirion mind accepting the last comment and merging with |
Should be OK now. Best, |
@adrinjalali do you want to have a look at this one now that the merge conflict is solved. |
Reference Issues/PRs
Fixes #18963
What does this implement/fix? Explain your changes.
In
grid_to_graph
, index the vertices according to mask structure, not their occurrence in edge matrix.Any other comments?
The text was updated successfully, but these errors were encountered: