MCPcopy Create free account
hub / github.com/numpy/numpy / _recursive_fill_value

Function _recursive_fill_value

numpy/ma/core.py:199–217  ·  view source on GitHub ↗

Recursively produce a fill value for `dtype`, calling f on scalar dtypes

(dtype, f)

Source from the content-addressed store, hash-verified

197del float_types_list
198
199def _recursive_fill_value(dtype, f):
200 """
201 Recursively produce a fill value for `dtype`, calling f on scalar dtypes
202 """
203 if dtype.names is not None:
204 # We wrap into `array` here, which ensures we use NumPy cast rules
205 # for integer casts, this allows the use of 99999 as a fill value
206 # for int8.
207 # TODO: This is probably a mess, but should best preserve behavior?
208 vals = tuple(
209 np.array(_recursive_fill_value(dtype[name], f))
210 for name in dtype.names)
211 return np.array(vals, dtype=dtype)[()] # decay to void scalar from 0d
212 elif dtype.subdtype:
213 subtype, shape = dtype.subdtype
214 subval = _recursive_fill_value(subtype, f)
215 return np.full(shape, subval)
216 else:
217 return f(dtype)
218
219
220def _get_dtype_of(obj):

Callers 2

default_fill_valueFunction · 0.85
_extremum_fill_valueFunction · 0.85

Calls 1

fFunction · 0.85

Tested by

no test coverage detected