Replace np.take by normal indexing. #13383
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
np.take(x, ind)
is equivalent tox.ravel()[ind]
andnp.take(x, ind, axis=0)
tox[ind]
(except for some details about contiguity of theoutput, not relevant to the changes here). Straight indexing is more
legible, so use that.
In pick_event_demo, additionally replace zip() by column_stack(), as,
on Py3, printing a zip() object results in
<zip object at 0xdeadbeef>
which is clearly not intended in the example.
In the same example,
np.nonzero()
always returns a 1-tuple (for 1dinputs), so the
if len(ind)
test always returned True and the pickerwould incorrectly fire even when clicking far away from the plotted
points. Fix that by unpacking the 1-tuple.
PR Summary
PR Checklist