MCPcopy Index your code
hub / github.com/numpy/numpy / _recursive_set_fill_value

Function _recursive_set_fill_value

numpy/ma/core.py:435–464  ·  view source on GitHub ↗

Create a fill value for a structured dtype. Parameters ---------- fillvalue : scalar or array_like Scalar or array representing the fill value. If it is of shorter length than the number of fields in dt, it will be resized. dt : dtype The structured dtyp

(fillvalue, dt)

Source from the content-addressed store, hash-verified

433
434
435def _recursive_set_fill_value(fillvalue, dt):
436 """
437 Create a fill value for a structured dtype.
438
439 Parameters
440 ----------
441 fillvalue : scalar or array_like
442 Scalar or array representing the fill value. If it is of shorter
443 length than the number of fields in dt, it will be resized.
444 dt : dtype
445 The structured dtype for which to create the fill value.
446
447 Returns
448 -------
449 val : tuple
450 A tuple of values corresponding to the structured fill value.
451
452 """
453 fillvalue = np.resize(fillvalue, len(dt.names))
454 output_value = []
455 for (fval, name) in zip(fillvalue, dt.names):
456 cdtype = dt[name]
457 if cdtype.subdtype:
458 cdtype = cdtype.subdtype[0]
459
460 if cdtype.names is not None:
461 output_value.append(tuple(_recursive_set_fill_value(fval, cdtype)))
462 else:
463 output_value.append(np.array(fval, dtype=cdtype).item())
464 return tuple(output_value)
465
466
467def _check_fill_value(fill_value, ndtype):

Callers 1

_check_fill_valueFunction · 0.85

Calls 2

resizeMethod · 0.80
itemMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…