Skip to content

BUG/MAINT/ENH: Allow viewing where only the last axis is contiguous #9497

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

Closed
wants to merge 2 commits into from

Conversation

eric-wieser
Copy link
Member

Also add a bunch of DECREFs

Fixes #9496

@jaimefrio
Copy link
Member

I can't seem to find the right discussions, but I believe forbidding this was a conscious decision. I did some work on this on #5508, which I believe @ahaldane picked up. #6562 may also have some information to what was done, but I have trouble understanding what the exact situation is right now.

@eric-wieser
Copy link
Member Author

So, your PR is a bad idea because it extends deprecated behaviour! Choosing the axis based on stride is a bad idea, which I suspect is why that behavior on Fortran arrays is now deprecated. This pr still only chooses the last axis.

@ahaldane's stuff I've seen and worked on elsewhere, but I don't think it's relevant here.

@eric-wieser
Copy link
Member Author

Oh, your PR raise s that this needs a special case when a dimension is size 1

@jaimefrio
Copy link
Member

I'm just saying that in the release notes of 1.11.0 we advertised the current behavior:

https://github.com/numpy/numpy/blob/master/doc/release/1.11.0-notes.rst#future-changes

So we should probably understand why that decision was taken before backpedaling on it.

@eric-wieser
Copy link
Member Author

The decision in 1.11 was the deprecation I mention in the issue this fixes. This isn't a backpedal, as the Fortran case continues to be deprecated, and the other cases were absent long before 1.1

You're right though, the rationale used for that deprecation can probably be applied to this too.

@jaimefrio
Copy link
Member

Think of a 2D sliding window type of view, where both axes have the same stride. The array is not contiguous, but its last dimension is. Say the array is of doubles and you take a complex dtype view of it. What do you do with the stride of the first axis? Leave it as is? Transform it like the last axis one? Whatever you do, it's going to be surprising to some users, hence probably better not to do it.

You could define something like "weak contiguousness", where the stride of each axis is required to be a multiple of the product of the size and stride of the next one, which would cover all arrays that are slices of contiguous arrays. And allow views like these to be taken on "weakly contiguous arrays with a strongly contiguous last dimension" only, probably with no issues like above. Not sure the benefit is worth the extra complexity.

@eric-wieser
Copy link
Member Author

eric-wieser commented Jul 31, 2017

Let's move discussion of this to #9496. I'm gonna close this PR, and file another that's just the MAINT part for now (#9499).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants