-
-
Notifications
You must be signed in to change notification settings - Fork 11k
MAINT: add overlap checks to choose, take, put, putmask #13182
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
7ad56c2
to
18a23bf
Compare
LGTM.
Is there an open |
The problem with "raise" is that it leaves the output array mutated when an error occurs (but not on the first index). So changing it could be seen as introducing a small issue itself. Advanced indexing assignment currently has similar issues but will simply allow for such mutation, which is not really ideal in a sense (many paths will check the index first, but not all do IIRC, have to check). |
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.
Looks good to me as well. Could be merged as is, but maybe we should add a short release note in any case.
18a23bf
to
aa1f3b4
Compare
Fixed. I also tweaked the Also, I notice in That code should be cleaned up. My suggestion is to just remove the |
aa1f3b4
to
a2df7b6
Compare
Hmm, can't say I care much which way we go on that function, both sounds fine to me (or even just leaving it, heh). For similarity with those other functions, I think I would tend slightly towards doing the copy, but contiguous input is probably the most common, so going the other way should actually be the smaller change. |
a2df7b6
to
a9d3ee9
Compare
Thanks, I see, you fixed the documentation, sounds good to me. If nobody else has a comment, I will merge it tomorrow or so. |
I guess this was ready to go in. Thanks Allan! |
Fixes #9293, #6272
This adds the overlap checks as suggested in #6272 to
np.choose
,np.take
,np.put
, andnp.putmask
.It is arguable whether or not this "fixes" #6272, since there are potentially more places overlap checks are needed, in particular in inplace operations. But at the very least this PR completes the checks listed by @seberg in #6272.
(Incidentally, I don't like that we always make a copy for
mode='raise'
innp.take/put
. It defeats the point of having anout
argument, which is to get no-copy performance!)