-
-
Notifications
You must be signed in to change notification settings - Fork 11k
np.swapaxes doesn't always return a view #5260
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
I agree that the lack of bounds checking is a bug. I'm not sure it matters On Tue, Nov 4, 2014 at 5:44 PM, Jaime notifications@github.com wrote:
Nathaniel J. Smith |
Sounds reasonable. I guess ideally returning the array or returning a view does not really matter, because |
There is actually the exact same issue with |
Always returning a view sounds right to me on first thought. |
Is there agreement on always returning a view? |
My work schedule has been crazy this past few weeks, but I will make a pull request later tonight. Will also ping the list when it is ready. |
Everyone seems lukewarmly in favor :-) |
ENH: Make swapaxes always return a view. Fixes #5260
Related somehow to the discussion in #5258. The docs for
np.swapaxes
state that it returns a view if the first argument is an ndarray, but it has a fast path foraxis1 == axis2
, where it actually returns the original array incref'ed:I prefer that it always returned a view, even if it is of the whole array unchanged, as the docs say, and as e.g.
np.transpose
does, even if the array is unchanged, and will be more than happy to submit a PR. If there is any good reason why this should not be the case, then at least the docs should be updated, and the check foraxis1 == axis2
be moved to after they have both been checked for in-boundness.The text was updated successfully, but these errors were encountered: