summaryrefslogtreecommitdiff
path: root/numpy/ma/core.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/ma/core.py')
-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 d3cbb33e5..a2f7c9e5c 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