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
(obj)
| 258 | |
| 259 | |
| 260 | def default_fill_value(obj): |
| 261 | """ |
| 262 | Return the default fill value for the argument object. |
| 263 | |
| 264 | The default filling value depends on the datatype of the input |
| 265 | array or the type of the input scalar: |
| 266 | |
| 267 | =========== ======== |
| 268 | datatype default |
| 269 | =========== ======== |
| 270 | bool True |
| 271 | int 999999 |
| 272 | float 1.e20 |
| 273 | complex 1.e20+0j |
| 274 | object '?' |
| 275 | string 'N/A' |
| 276 | StringDType 'N/A' |
| 277 | =========== ======== |
| 278 | |
| 279 | For structured types, a structured scalar is returned, with each field the |
| 280 | default fill value for its type. |
| 281 | |
| 282 | For subarray types, the fill value is an array of the same size containing |
| 283 | the default scalar fill value. |
| 284 | |
| 285 | Parameters |
| 286 | ---------- |
| 287 | obj : ndarray, dtype or scalar |
| 288 | The array data-type or scalar for which the default fill value |
| 289 | is returned. |
| 290 | |
| 291 | Returns |
| 292 | ------- |
| 293 | fill_value : scalar |
| 294 | The default fill value. |
| 295 | |
| 296 | Examples |
| 297 | -------- |
| 298 | >>> import numpy as np |
| 299 | >>> np.ma.default_fill_value(1) |
| 300 | 999999 |
| 301 | >>> np.ma.default_fill_value(np.array([1.1, 2., np.pi])) |
| 302 | 1e+20 |
| 303 | >>> np.ma.default_fill_value(np.dtype(complex)) |
| 304 | (1e+20+0j) |
| 305 | |
| 306 | """ |
| 307 | def _scalar_fill_value(dtype): |
| 308 | if dtype.kind in 'Mm': |
| 309 | return default_filler.get(dtype.str[1:], '?') |
| 310 | else: |
| 311 | return default_filler.get(dtype.kind, '?') |
| 312 | |
| 313 | dtype = _get_dtype_of(obj) |
| 314 | return _recursive_fill_value(dtype, _scalar_fill_value) |
| 315 | |
| 316 | |
| 317 | def _extremum_fill_value(obj, extremum, extremum_name): |
searching dependent graphs…