From 03aa7f92b95d3c9ce7230d98664984a663bac0af Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Sun, 22 Mar 2020 14:20:33 +0000 Subject: MAINT: Add an explanatory comment for some weird code --- numpy/lib/function_base.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'numpy/lib/function_base.py') diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index b9f3bbb16..e68b9f2ef 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -4270,6 +4270,7 @@ def delete(arr, obj, axis=None): if axis is None: if ndim != 1: arr = arr.ravel() + # needed for np.matrix, which is still not 1d after being ravelled ndim = arr.ndim axis = -1 @@ -4510,6 +4511,7 @@ def insert(arr, obj, values, axis=None): if axis is None: if ndim != 1: arr = arr.ravel() + # needed for np.matrix, which is still not 1d after being ravelled ndim = arr.ndim axis = ndim - 1 elif ndim == 0: -- cgit v1.2.1 From cf377c766d6ac8d72116bc71ad5c9d2f29996e03 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Sun, 22 Mar 2020 14:21:18 +0000 Subject: MAINT: Remove some weird syntax for kwargs --- numpy/lib/function_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/lib/function_base.py') diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index e68b9f2ef..b3ad433cd 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -4533,7 +4533,7 @@ def insert(arr, obj, values, axis=None): if isinstance(obj, slice): # turn it into a range object - indices = arange(*obj.indices(N), **{'dtype': intp}) + indices = arange(*obj.indices(N), dtype=intp) else: # need to copy obj, because indices will be changed in-place indices = np.array(obj) -- cgit v1.2.1 From 566c84bfda3ac656232600445442cdf74bc84569 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Sun, 22 Mar 2020 14:36:12 +0000 Subject: MAINT: Add missing deprecation dates and versions --- numpy/lib/function_base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'numpy/lib/function_base.py') diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index b3ad433cd..6c7786860 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -4345,6 +4345,7 @@ def delete(arr, obj, axis=None): # After removing the special handling of booleans and out of # bounds values, the conversion to the array can be removed. if obj.dtype == bool: + # 2012-10-11, NumPy 1.8 warnings.warn("in the future insert will treat boolean arrays and " "array-likes as boolean index instead of casting it " "to integer", FutureWarning, stacklevel=3) @@ -4382,7 +4383,7 @@ def delete(arr, obj, axis=None): # 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, 1.9 + # 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`.", @@ -4390,6 +4391,7 @@ def delete(arr, obj, axis=None): 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) @@ -4539,6 +4541,7 @@ def insert(arr, obj, values, axis=None): indices = np.array(obj) if indices.dtype == bool: # See also delete + # 2012-10-11, NumPy 1.8 warnings.warn( "in the future insert will treat boolean arrays and " "array-likes as a boolean index instead of casting it to " -- cgit v1.2.1 From 90e644e7c668d52155e9a07b1032e71974e3dc7d Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Sun, 22 Mar 2020 14:38:55 +0000 Subject: MAINT: Make the axis logic for delete match insert. No behavior change here unless someone implements a subclass where `arr.ravel().ndim == 0`, which no sane person would do anyway. --- numpy/lib/function_base.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'numpy/lib/function_base.py') diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 6c7786860..1c67f7c99 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -4272,9 +4272,8 @@ def delete(arr, obj, axis=None): arr = arr.ravel() # needed for np.matrix, which is still not 1d after being ravelled ndim = arr.ndim - axis = -1 - - if ndim == 0: + axis = ndim - 1 + elif ndim == 0: # 2013-09-24, 1.9 warnings.warn( "in the future the special handling of scalars will be removed " @@ -4283,8 +4282,8 @@ def delete(arr, obj, axis=None): return wrap(arr) else: return arr.copy(order=arrorder) - - axis = normalize_axis_index(axis, ndim) + else: + axis = normalize_axis_index(axis, ndim) slobj = [slice(None)]*ndim N = arr.shape[axis] -- cgit v1.2.1