-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: np.unique
with return_inverse
and axis
specification yields a wrong shape
#26738
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
Comments
This was intentional: https://numpy.org/devdocs/release/2.0.0-notes.html#np-unique-return-inverse-shape-for-multi-dimensional-inputs It is now compatible with But we may have underestimated the impact of this choice, and whether it is even the right one, since previously it was compatible with The reason for this compatibility is that unlike To clarify, let me invent a different operation that behaves similar to
The That means that both choices make sense, since using One option is just to undo this for Unless we could even reconsider it for the |
Ah, one thing I missed and this does indeed improve, is that for |
@nabenabe0928 I forgot to mention that the work-around is to add a |
@seberg Tbh, I did not know This breaking change was a bit troublesome for me because I was using Note I know that there is Anyways, given the context that the change is intended, I will simply use |
For what it's worth, this was the kind of issue I had in mind when I commented here on the original PR: #25553 (comment), but the NumPy team together decided that the breaking change was warranted: #25553 (comment) I'm not sure whether there are any public notes from that discussion. |
Right, the thing that I misunderstood, is that I had the impression that new behavior was chosen because the old behavior was very strange. But that seems wrong, I am not even sure why the new behavior is in any serious way better right now (besides for Dunno, its public, but of there are unlikely to be detailed enough notes. |
Closing, this is reverted. Note that the shape did change in 2.0 for the first case you mentioned and will stay changed. The first example actually didn't work previously. |
Describe the issue:
In NumPy v2.0.0, when I specify
return_inverse=True
andaxis
for a 2d array,np.unique
will return a wrongly deep-nested array for the inverse.Reproduce the code example:
Error message:
No response
Python and NumPy Versions:
[GCC 11.2.0]
Runtime Environment:
No response
Context for the issue:
No response
The text was updated successfully, but these errors were encountered: