diff options
| author | Charles Harris <charlesr.harris@gmail.com> | 2022-06-28 14:24:24 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-28 14:24:24 -0600 |
| commit | 00f59f633402b8d31261cc75f42a8986add89659 (patch) | |
| tree | a5183ecd9f03171fed12ba23c349494e06837181 /numpy/lib/function_base.py | |
| parent | 4d107955b93f2def7748cce129bd13b79746065b (diff) | |
| parent | 563974c45415a4919776eb7f9254c49ee60f30a5 (diff) | |
| download | numpy-00f59f633402b8d31261cc75f42a8986add89659.tar.gz | |
Merge pull request #21870 from charris/backport-21857
BUG: Reject non integer array-likes with size 1 in delete
Diffstat (limited to 'numpy/lib/function_base.py')
| -rw-r--r-- | numpy/lib/function_base.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index d90c23bfe..ca82bb72d 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -5140,10 +5140,14 @@ def delete(arr, obj, axis=None): single_value = False _obj = obj obj = np.asarray(obj) + # `size == 0` to allow empty lists similar to indexing, but (as there) + # is really too generic: if obj.size == 0 and not isinstance(_obj, np.ndarray): obj = obj.astype(intp) - elif obj.size == 1 and not isinstance(_obj, bool): - obj = obj.astype(intp).reshape(()) + elif obj.size == 1 and obj.dtype.kind in "ui": + # For a size 1 integer array we can use the single-value path + # (most dtypes, except boolean, should just fail later). + obj = obj.item() single_value = True if single_value: |
