MCPcopy Create free account
hub / github.com/numpy/numpy / _array_str_implementation

Function _array_str_implementation

numpy/core/arrayprint.py:1595–1612  ·  view source on GitHub ↗

Internal version of array_str() that allows overriding array2string.

(
        a, max_line_width=None, precision=None, suppress_small=None,
        array2string=array2string)

Source from the content-addressed store, hash-verified

1593
1594
1595def _array_str_implementation(
1596 a, max_line_width=None, precision=None, suppress_small=None,
1597 array2string=array2string):
1598 """Internal version of array_str() that allows overriding array2string."""
1599 if (_format_options['legacy'] <= 113 and
1600 a.shape == () and not a.dtype.names):
1601 return str(a.item())
1602
1603 # the str of 0d arrays is a special case: It should appear like a scalar,
1604 # so floats are not truncated by `precision`, and strings are not wrapped
1605 # in quotes. So we return the str of the scalar value.
1606 if a.shape == ():
1607 # obtain a scalar and call str on it, avoiding problems for subclasses
1608 # for which indexing with () returns a 0d instead of a scalar by using
1609 # ndarray's getindex. Also guard against recursive 0d object arrays.
1610 return _guarded_repr_or_str(np.ndarray.__getitem__(a, ()))
1611
1612 return array2string(a, max_line_width, precision, suppress_small, ' ', "")
1613
1614
1615def _array_str_dispatcher(

Callers 1

array_strFunction · 0.85

Calls 4

_guarded_repr_or_strFunction · 0.85
array2stringFunction · 0.85
itemMethod · 0.80
__getitem__Method · 0.45

Tested by

no test coverage detected