diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2020-03-22 19:57:47 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2020-03-22 20:29:49 +0000 |
commit | 849756ff1582ad46d14b7ff621a6e524337304f9 (patch) | |
tree | cfe84a81da89e3fe16d78c6e19a839513bee2c35 /numpy/lib/tests/test_function_base.py | |
parent | 90e644e7c668d52155e9a07b1032e71974e3dc7d (diff) | |
download | numpy-849756ff1582ad46d14b7ff621a6e524337304f9.tar.gz |
DEP: Forbid passing non-integral index arrays to `insert` and `delete`
This expires a deprecation warning from back in 1.9.
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 860cf452b..a5988a719 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -544,6 +544,12 @@ class TestInsert: b = np.insert(a, [0, 2], val) assert_array_equal(b[[0, 3]], np.array(val, dtype=b.dtype)) + def test_index_floats(self): + with pytest.raises(IndexError): + np.insert([0, 1, 2], np.array([1.0, 2.0]), [10, 20]) + with pytest.raises(IndexError): + np.insert([0, 1, 2], np.array([], dtype=float), []) + class TestAmax: @@ -868,6 +874,12 @@ class TestDelete: assert_equal(m.flags.c_contiguous, k.flags.c_contiguous) assert_equal(m.flags.f_contiguous, k.flags.f_contiguous) + def test_index_floats(self): + with pytest.raises(IndexError): + np.delete([0, 1, 2], np.array([1.0, 2.0])) + with pytest.raises(IndexError): + np.delete([0, 1, 2], np.array([], dtype=float)) + class TestGradient: |