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)
| 433 | |
| 434 | |
| 435 | def _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 | |
| 467 | def _check_fill_value(fill_value, ndtype): |
no test coverage detected
searching dependent graphs…