DEP: Make np.delete on out-of-bounds indices an error#15804
DEP: Make np.delete on out-of-bounds indices an error#15804seberg merged 1 commit intonumpy:masterfrom
Conversation
Note that this only affects lists of indices. ```python >>> a = np.arange(3) ```` Before: ```python >>> np.delete(a, 100) IndexError >>> np.delete(a, [100]) DeprecationWarning array([0, 1, 2]) >>> np.delete(a, -1) array([0, 1]) >>> np.delete(a, [-1]) FutureWarning array([0, 1, 2]) ``` After: ```python >>> np.delete(a, 100) IndexError >>> np.delete(a, [100]) IndexError >>> np.delete(a, -1) array([0, 1]) >>> np.delete(a, [-1]) array([0, 1]) ```
cc162bf to
68563e9
Compare
|
Thanks Eric, LGTM. |
| with warnings.catch_warnings(record=True) as w: | ||
| warnings.filterwarnings('always', category=FutureWarning) | ||
| self._check_inverse_of_slicing([0, -1, 2, 2]) |
There was a problem hiding this comment.
I'm pretty sure I made a mistake in this patch, I'd expect this to produce one fewer warning, yet it appears to pass.
There was a problem hiding this comment.
Hmmm, strange, then why did this not fail? There are two delete calls in there, but the FutureWarning that is being detected here must not be the one that you deleted. Maybe something completely unrelated?
There was a problem hiding this comment.
Wait, below the boolean index still gives a futurewarning right? And there are two calls of delete. So I guess it should have checked the warnings 4 times, or reset in between the two checks simply. Seems fair enough, the boolean fixup just needs to delete it all.
EDIT: Nvm. I see you already opened a PR to that effect.
Since numpy 1.19, `np.delete` came to fail on out-of-bounds indices (numpy/numpy#15804) and pandas will as well since it depends on numpy.
Since numpy 1.19, `np.delete` came to fail on out-of-bounds indices (numpy/numpy#15804) and pandas will as well since it depends on numpy.
Note that this only affects lists of indices.
Before:
After:
Similar to gh-15802