summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2020-03-25 04:59:27 +0000
committerGitHub <noreply@github.com>2020-03-25 00:59:27 -0400
commitb03c575834a68f3a8dad5e2974ccee7fa76003ac (patch)
tree548c378c3fa17186f59e0c149b93300da92746ab /numpy/lib/tests/test_function_base.py
parentfed47a489e3da26fffb98a6dda32dbc9ba0f63c3 (diff)
downloadnumpy-b03c575834a68f3a8dad5e2974ccee7fa76003ac.tar.gz
DEP: Do not cast boolean indices to integers in np.delete (#15815)
This expires a deprecation from 1.8. The corresponding deprecation in `np.insert` has less clear semantics, so has been left to a future patch. Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net> Co-authored-by: Warren Weckesser <warren.weckesser@gmail.com>
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index fb10205d4..3e621f077 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -809,9 +809,6 @@ class TestDelete:
a_del = delete(self.a, indices)
nd_a_del = delete(self.nd_a, indices, axis=1)
msg = 'Delete failed for obj: %r' % indices
- # 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)
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])
@@ -827,7 +824,6 @@ class TestDelete:
self._check_inverse_of_slicing(s)
def test_fancy(self):
- # Deprecation/FutureWarning tests should be kept after change.
self._check_inverse_of_slicing(np.array([[0, 1], [2, 1]]))
with pytest.raises(IndexError):
delete(self.a, [100])
@@ -836,14 +832,17 @@ class TestDelete:
self._check_inverse_of_slicing([0, -1, 2, 2])
- with warnings.catch_warnings(record=True) as w:
- warnings.filterwarnings('always', category=FutureWarning)
- obj = np.array([True, False, False], dtype=bool)
- self._check_inverse_of_slicing(obj)
- # _check_inverse_of_slicing operates on two arrays, so warns twice
- assert len(w) == 2
- assert_(w[0].category is FutureWarning)
- assert_(w[1].category is FutureWarning)
+ self._check_inverse_of_slicing([True, False, False, True, False])
+
+ # not legal, indexing with these would change the dimension
+ with pytest.raises(ValueError):
+ delete(self.a, True)
+ with pytest.raises(ValueError):
+ delete(self.a, False)
+
+ # not enough items
+ with pytest.raises(ValueError):
+ delete(self.a, [False]*4)
def test_single(self):
self._check_inverse_of_slicing(0)