summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2020-03-23 10:12:07 -0500
committerGitHub <noreply@github.com>2020-03-23 10:12:07 -0500
commitd5010b129e4f3714dcad04eb7115372848fbce36 (patch)
treec1db6f57913f97d2896024c9ce838f520f1e90e4 /numpy
parent9ae4a0d1ebc52a556ed13248172e8280ad9fc6bd (diff)
parent68563e997aab1208c71efec5698c24214d840cda (diff)
downloadnumpy-d5010b129e4f3714dcad04eb7115372848fbce36.tar.gz
Merge pull request #15804 from eric-wieser/expire-delete-out-of-bounds
DEP: Make np.delete on out-of-bounds indices an error
Diffstat (limited to 'numpy')
-rw-r--r--numpy/lib/function_base.py17
-rw-r--r--numpy/lib/tests/test_function_base.py9
2 files changed, 4 insertions, 22 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index d39ee63b6..a49c34741 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -4371,23 +4371,6 @@ def delete(arr, obj, axis=None):
obj = obj.astype(intp)
keep = ones(N, dtype=bool)
- # Test if there are out of bound indices, this is deprecated
- inside_bounds = (obj < N) & (obj >= -N)
- if not inside_bounds.all():
- # 2013-09-24, NumPy 1.9
- warnings.warn(
- "in the future out of bounds indices will raise an error "
- "instead of being ignored by `numpy.delete`.",
- DeprecationWarning, stacklevel=3)
- obj = obj[inside_bounds]
- positive_indices = obj >= 0
- if not positive_indices.all():
- # 2013-04-11, NumPy 1.8
- warnings.warn(
- "in the future negative indices will not be ignored by "
- "`numpy.delete`.", FutureWarning, stacklevel=3)
- obj = obj[positive_indices]
-
keep[obj, ] = False
slobj[axis] = keep
new = arr[tuple(slobj)]
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index a5988a719..05e5bff50 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -813,7 +813,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])
@@ -831,10 +830,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])