diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2020-03-22 20:09:54 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2020-03-22 20:15:56 +0000 |
commit | 68563e997aab1208c71efec5698c24214d840cda (patch) | |
tree | 9c27125f17d7ae782fe91720be4d16a66730e6df /numpy/lib/function_base.py | |
parent | 90e644e7c668d52155e9a07b1032e71974e3dc7d (diff) | |
download | numpy-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/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 1c67f7c99..e6c3322e2 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -4379,23 +4379,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)] |