Internal version of array_str() that allows overriding array2string.
(
a, max_line_width=None, precision=None, suppress_small=None,
array2string=array2string)
| 1593 | |
| 1594 | |
| 1595 | def _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 | |
| 1615 | def _array_str_dispatcher( |
no test coverage detected