summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2020-03-22 20:09:54 +0000
committerEric Wieser <wieser.eric@gmail.com>2020-03-22 20:15:56 +0000
commit68563e997aab1208c71efec5698c24214d840cda (patch)
tree9c27125f17d7ae782fe91720be4d16a66730e6df /numpy/lib/tests/test_function_base.py
parent90e644e7c668d52155e9a07b1032e71974e3dc7d (diff)
downloadnumpy-68563e997aab1208c71efec5698c24214d840cda.tar.gz
DEP: Make np.delete on out-of-bounds indices an error
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]) ```
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 860cf452b..b29e75471 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -807,7 +807,6 @@ class TestDelete:
# NOTE: The cast should be removed after warning phase for bools
if not isinstance(indices, (slice, int, long, np.integer)):
indices = np.asarray(indices, dtype=np.intp)
- indices = indices[(indices >= 0) & (indices < 5)]
assert_array_equal(setxor1d(a_del, self.a[indices, ]), self.a,
err_msg=msg)
xor = setxor1d(nd_a_del[0,:, 0], self.nd_a[0, indices, 0])
@@ -825,10 +824,10 @@ class TestDelete:
def test_fancy(self):
# Deprecation/FutureWarning tests should be kept after change.
self._check_inverse_of_slicing(np.array([[0, 1], [2, 1]]))
- with warnings.catch_warnings():
- warnings.filterwarnings('error', category=DeprecationWarning)
- assert_raises(DeprecationWarning, delete, self.a, [100])
- assert_raises(DeprecationWarning, delete, self.a, [-100])
+ with pytest.raises(IndexError):
+ delete(self.a, [100])
+ with pytest.raises(IndexError):
+ delete(self.a, [-100])
with warnings.catch_warnings(record=True) as w:
warnings.filterwarnings('always', category=FutureWarning)
self._check_inverse_of_slicing([0, -1, 2, 2])