Return the default fill value for the argument object. The default filling value depends on the datatype of the input array or the type of the input scalar: ======== ======== datatype default ======== ======== bool True int 999999
(obj)
| 228 | |
| 229 | |
| 230 | def default_fill_value(obj): |
| 231 | """ |
| 232 | Return the default fill value for the argument object. |
| 233 | |
| 234 | The default filling value depends on the datatype of the input |
| 235 | array or the type of the input scalar: |
| 236 | |
| 237 | ======== ======== |
| 238 | datatype default |
| 239 | ======== ======== |
| 240 | bool True |
| 241 | int 999999 |
| 242 | float 1.e20 |
| 243 | complex 1.e20+0j |
| 244 | object '?' |
| 245 | string 'N/A' |
| 246 | ======== ======== |
| 247 | |
| 248 | For structured types, a structured scalar is returned, with each field the |
| 249 | default fill value for its type. |
| 250 | |
| 251 | For subarray types, the fill value is an array of the same size containing |
| 252 | the default scalar fill value. |
| 253 | |
| 254 | Parameters |
| 255 | ---------- |
| 256 | obj : ndarray, dtype or scalar |
| 257 | The array data-type or scalar for which the default fill value |
| 258 | is returned. |
| 259 | |
| 260 | Returns |
| 261 | ------- |
| 262 | fill_value : scalar |
| 263 | The default fill value. |
| 264 | |
| 265 | Examples |
| 266 | -------- |
| 267 | >>> np.ma.default_fill_value(1) |
| 268 | 999999 |
| 269 | >>> np.ma.default_fill_value(np.array([1.1, 2., np.pi])) |
| 270 | 1e+20 |
| 271 | >>> np.ma.default_fill_value(np.dtype(complex)) |
| 272 | (1e+20+0j) |
| 273 | |
| 274 | """ |
| 275 | def _scalar_fill_value(dtype): |
| 276 | if dtype.kind in 'Mm': |
| 277 | return default_filler.get(dtype.str[1:], '?') |
| 278 | else: |
| 279 | return default_filler.get(dtype.kind, '?') |
| 280 | |
| 281 | dtype = _get_dtype_of(obj) |
| 282 | return _recursive_fill_value(dtype, _scalar_fill_value) |
| 283 | |
| 284 | |
| 285 | def _extremum_fill_value(obj, extremum, extremum_name): |