Skip to content

API: Make a.flat.__array__ return a copy when a non-contiguous. #9447

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

Merged
merged 2 commits into from
Sep 5, 2017

Conversation

charris
Copy link
Member

@charris charris commented Jul 21, 2017

Previously an UPDATEIFCOPY array was returned when a was non-contiguous
and writeable. Exposing that type of array does not work well with PyPy
as it doesn't do refcounting, and hence the writeback never occurs. The copy that
is now returned instead is set to non-writable to expose cases where a writeback
was expected. At some future date the copy will be made writable. See
gh-7054 for a discussion of this issue.

* If underlying array is readonly, then we make the output array readonly
* and updateifcopy does not apply.
*
* Changed for 1.14, 07/21/2017.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: 2017-07-21. Let's make searching for dates easy on ourselves

@eric-wieser
Copy link
Member

Ignoring the temporary readonly flag, will np.asarray(x.flat) always be the same as x.ravel() after this change?

@charris charris force-pushed the transition-flat.__array__ branch from d84fdba to 6de4bf1 Compare July 22, 2017 13:45
@charris
Copy link
Member Author

charris commented Jul 22, 2017

Fixed.

@charris
Copy link
Member Author

charris commented Jul 22, 2017

Ignoring the temporary readonly flag, will np.asarray(x.flat) always be the same as x.ravel() after this change?

Yes.

@eric-wieser
Copy link
Member

Shouldn't this be API? Also, if this is making 1.14, can we get a warning into 1.13.2?

@mattip
Copy link
Member

mattip commented Jul 23, 2017

replaces pull request #9249, correct?

@charris charris changed the title ENH, DEP: Make a.flat.__array__ return a copy when a non-contiguous. ENH, DEP: Make a.flat.__array__ return a copy when a non-contiguous. Jul 23, 2017
@charris charris changed the title ENH, DEP: Make a.flat.__array__ return a copy when a non-contiguous. API: Make a.flat.__array__ return a copy when a non-contiguous. Jul 23, 2017
@charris
Copy link
Member Author

charris commented Jul 23, 2017

@eric-wieser This isn't a warning, it is an outright change of behavior. We are going to gamble that few, if any, folks will be affected, but if so we want to know. If this doesn't work we might fall back to a warning.

@eric-wieser
Copy link
Member

eric-wieser commented Jul 23, 2017

I realize - but if we're going to do an outright change in 1.14, we still have time to stick a warning into 1.13.2 that it's about to happen, so we should

@charris
Copy link
Member Author

charris commented Jul 24, 2017

The only reason for 1.13.2 is to build wheels against 3.6.2, otherwise the 1.13 release cycle is done unless a grievous error turns up. I don't want people to be bothered with new error/warning messages. We have already decided not to issue a warning in any case.

Previously an UPDATEIFCOPY array was returned when `a` was
non-contiguous and writeable. Exposing that type of array does not work
well with PyPy as there is no refcount, and hence the writeback never
occurs. The copy in this case is set to non-writable to expose cases
where a writeback was expected. At some future time the copy will be
made writable. See numpygh-7054 for a discussion of this issue. It is not
expected that this change will affect many people.
@charris charris force-pushed the transition-flat.__array__ branch from 6de4bf1 to 5a5f1a3 Compare September 5, 2017 20:21
@@ -50,6 +56,16 @@ Build System Changes
Compatibility notes
===================

``a.flat.__array__()`` returns non-writeable arrays when ``a`` is non-contiguos
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling: contiguos → contiguous

@njsmith
Copy link
Member

njsmith commented Sep 5, 2017

Otherwise LGTM. Feel free to merge after fixing the typo :-)

@njsmith
Copy link
Member

njsmith commented Sep 5, 2017

Oh wait a sec, I can just fix the typo myself. The future!

@njsmith njsmith merged commit cf7ba54 into numpy:master Sep 5, 2017
@eric-wieser
Copy link
Member

Not while using a commit prefix, it seems ;)

@njsmith
Copy link
Member

njsmith commented Sep 6, 2017

@eric-wieser: I squashed it out when merging anyway :-P

@eric-wieser
Copy link
Member

Would be nice if the github UI would indicate whether a squash merge was used

theodoregoetz pushed a commit to theodoregoetz/numpy that referenced this pull request Oct 23, 2017
…s. (numpy#9447)

* API: Make ``a.flat.__array__`` return copy if ``a`` non-contiguous.

Previously an UPDATEIFCOPY array was returned when `a` was
non-contiguous and writeable. Exposing that type of array does not work
well with PyPy as there is no refcount, and hence the writeback never
occurs. The copy in this case is set to non-writable to expose cases
where a writeback was expected. At some future time the copy will be
made writable. See numpygh-7054 for a discussion of this issue. It is not
expected that this change will affect many people.
@charris charris deleted the transition-flat.__array__ branch May 15, 2019 01:52
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.

4 participants