Implements the repr for structured-void scalars. It is called from the scalartypes.c.src code, and is placed here because it uses the elementwise formatters defined above.
(x, is_repr=True)
| 1499 | |
| 1500 | |
| 1501 | def _void_scalar_to_string(x, is_repr=True): |
| 1502 | """ |
| 1503 | Implements the repr for structured-void scalars. It is called from the |
| 1504 | scalartypes.c.src code, and is placed here because it uses the elementwise |
| 1505 | formatters defined above. |
| 1506 | """ |
| 1507 | options = format_options.get().copy() |
| 1508 | |
| 1509 | if options["legacy"] <= 125: |
| 1510 | return StructuredVoidFormat.from_data(array(x), **options)(x) |
| 1511 | |
| 1512 | if options.get('formatter') is None: |
| 1513 | options['formatter'] = {} |
| 1514 | options['formatter'].setdefault('float_kind', str) |
| 1515 | val_repr = StructuredVoidFormat.from_data(array(x), **options)(x) |
| 1516 | if not is_repr: |
| 1517 | return val_repr |
| 1518 | cls = type(x) |
| 1519 | cls_fqn = cls.__module__.replace("numpy", "np") + "." + cls.__name__ |
| 1520 | void_dtype = np.dtype((np.void, x.dtype)) |
| 1521 | return f"{cls_fqn}({val_repr}, dtype={void_dtype!s})" |
| 1522 | |
| 1523 | |
| 1524 | _typelessdata = [int_, float64, complex128, _nt.bool] |