-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
ENH: Always produce a consistent shape in the result of argwhere
#13610
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
Conversation
Looking downstream - I suspect the only users actually affected by this will be the ones who have code that is currently broken on 0d arrays anyway. |
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.
One small comment about the docstring changes.
But a larger one overall: isn't it really better to just change nonzero
? See #13522 (comment)
numpy/core/fromnumeric.py
Outdated
|
||
transpose(nonzero(a)) | ||
|
||
To group the indices by element, rather than dimension, use `argwhere`. |
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.
Probably good to also mention argwhere
in the See also
section.
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.
Lets maybe put this off to 1.18? I like the change, but hope it is not too bold. But then the current 0-D behaviour is pretty broken. Tests also look good. It definitely will need a release note though.
We do have a .. versionchanged::
tag, which I think we should use in the notes Section here.
If we're deprecating nonzero for this case, we probably need an implementation here that does not use it. |
Don't think there's any way for me to write release notes if we do that. Opening #13707 to track solutions to that problem. |
7358413
to
9d1b7dd
Compare
Updated with a release note |
Failing:
|
9d1b7dd
to
586e3a2
Compare
Yep, caught out by a rebase. Had to tweak the imports some more to avoid cycles. |
Builds are failing:
|
Previously this would return 1d indices even though the array is zero-d. Note that using atleast1d inside numeric required an import change to avoid a circular import.
586e3a2
to
b6a3ee3
Compare
Looks all good to me. Lets give it a shot for 1.18. The quest for making 0D arrays not weird continues :). |
Previously this would return 1d indices even though the array is zero-d.
Also update the docs to remove recommending the use of
tranpose(nonzero(a))
.Inspired by #13522 - we can't easily fix
nonzero
, but we can fix downstream uses.