-
-
Notifications
You must be signed in to change notification settings - Fork 11k
DOC rollaxis return value is a view of input #5258
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
@@ -1392,7 +1392,7 @@ def rollaxis(a, axis, start=0): | |||
Returns | |||
------- | |||
res : ndarray | |||
Output array. | |||
`a` with its axes permuted. A view is returned whenever possible. |
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.
It is always possible to return a view.
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.
Okay. I copied from transpose
and thought it safer to keep the hedge until it could be confirmed.
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.
In that case, it sounds like transpose documentation should be fixed as well.
Is this correct for the current verson? I'm thinking of the comments at #5260. |
No it is not:
This is easy to fix: in line 1425, replace the current
with
|
If we make this change, it needs to be mentioned in the 1.10 release notes, maybe in the compatibility section. |
So in no case is the array copied, but currently there are some cases where the input is returned without creating a new view. I don't see why making it always return a view would change any intentional behaviour, but it might be considered a bug-fix. |
You would be surprised how much code can break because it depends on such "features", often by accident ;) |
Yes, I already know to be surprised... But, really, users taking advantage of a no-op call to mutate the array attributes? |
Frankly, didn't hear complains about |
To be fair, it's about as likely in this case that there is code which On Tue, Nov 11, 2014 at 11:59 PM, seberg notifications@github.com wrote:
Nathaniel J. Smith |
@jnothman Could you make the change suggested by @jaimefrio. Always returning a view seems to be the consensus. |
Ah, yes, sorry I didn't get back on this. I hadn't been sure what the exact fix should be wrt dev comments above. I should have commented so, but I'm glad it's being fixed up in any case. |
No description provided.