diff options
Diffstat (limited to 'numpy/ma')
| -rw-r--r-- | numpy/ma/core.py | 8 |
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 |
