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

Function _void_scalar_to_string

numpy/_core/arrayprint.py:1501–1521  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1499
1500
1501def _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]

Callers

nothing calls this directly

Calls 6

arrayFunction · 0.90
from_dataMethod · 0.80
replaceMethod · 0.80
copyMethod · 0.45
getMethod · 0.45
dtypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…