summaryrefslogtreecommitdiff
path: root/numpy/ma
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2022-10-11 19:34:59 +0300
committerGitHub <noreply@github.com>2022-10-11 19:34:59 +0300
commit226f9c537ff9c0da56884f5ef5b5220c6c3629e9 (patch)
tree107da63c0a668868406571953aabc03f89adb099 /numpy/ma
parent7036b164ed1d59df870c35a90ab2e6148ba976cc (diff)
parent5f1102429b0602e9ed6ad644295dc8f3f7a43b95 (diff)
downloadnumpy-226f9c537ff9c0da56884f5ef5b5220c6c3629e9.tar.gz
Merge pull request #22385 from seberg/deprecate-out-of-bound-pyint-conversion
DEP: Deprecate conversion of out-of-bound Python integers
Diffstat (limited to 'numpy/ma')
-rw-r--r--numpy/ma/core.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 902a25b67..ba01f3e2e 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -201,7 +201,13 @@ def _recursive_fill_value(dtype, f):
Recursively produce a fill value for `dtype`, calling f on scalar dtypes
"""
if dtype.names is not None:
- vals = tuple(_recursive_fill_value(dtype[name], f) for name in dtype.names)
+ # We wrap into `array` here, which ensures we use NumPy cast rules
+ # for integer casts, this allows the use of 99999 as a fill value
+ # for int8.
+ # TODO: This is probably a mess, but should best preserve behavior?
+ vals = tuple(
+ np.array(_recursive_fill_value(dtype[name], f))
+ for name in dtype.names)
return np.array(vals, dtype=dtype)[()] # decay to void scalar from 0d
elif dtype.subdtype:
subtype, shape = dtype.subdtype