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)
| 399 | |
| 400 | |
| 401 | def _recursive_set_fill_value(fillvalue, dt): |
| 402 | """ |
| 403 | Create a fill value for a structured dtype. |
| 404 | |
| 405 | Parameters |
| 406 | ---------- |
| 407 | fillvalue : scalar or array_like |
| 408 | Scalar or array representing the fill value. If it is of shorter |
| 409 | length than the number of fields in dt, it will be resized. |
| 410 | dt : dtype |
| 411 | The structured dtype for which to create the fill value. |
| 412 | |
| 413 | Returns |
| 414 | ------- |
| 415 | val : tuple |
| 416 | A tuple of values corresponding to the structured fill value. |
| 417 | |
| 418 | """ |
| 419 | fillvalue = np.resize(fillvalue, len(dt.names)) |
| 420 | output_value = [] |
| 421 | for (fval, name) in zip(fillvalue, dt.names): |
| 422 | cdtype = dt[name] |
| 423 | if cdtype.subdtype: |
| 424 | cdtype = cdtype.subdtype[0] |
| 425 | |
| 426 | if cdtype.names is not None: |
| 427 | output_value.append(tuple(_recursive_set_fill_value(fval, cdtype))) |
| 428 | else: |
| 429 | output_value.append(np.array(fval, dtype=cdtype).item()) |
| 430 | return tuple(output_value) |
| 431 | |
| 432 | |
| 433 | def _check_fill_value(fill_value, ndtype): |
no test coverage detected