Internal version of array_str() that allows overriding array2string.
(
a, max_line_width=None, precision=None, suppress_small=None,
array2string=array2string)
| 1715 | |
| 1716 | |
| 1717 | def _array_str_implementation( |
| 1718 | a, max_line_width=None, precision=None, suppress_small=None, |
| 1719 | array2string=array2string): |
| 1720 | """Internal version of array_str() that allows overriding array2string.""" |
| 1721 | if (format_options.get()['legacy'] <= 113 and |
| 1722 | a.shape == () and not a.dtype.names): |
| 1723 | return str(a.item()) |
| 1724 | |
| 1725 | # the str of 0d arrays is a special case: It should appear like a scalar, |
| 1726 | # so floats are not truncated by `precision`, and strings are not wrapped |
| 1727 | # in quotes. So we return the str of the scalar value. |
| 1728 | if a.shape == (): |
| 1729 | # obtain a scalar and call str on it, avoiding problems for subclasses |
| 1730 | # for which indexing with () returns a 0d instead of a scalar by using |
| 1731 | # ndarray's getindex. Also guard against recursive 0d object arrays. |
| 1732 | return _guarded_repr_or_str(np.ndarray.__getitem__(a, ())) |
| 1733 | |
| 1734 | return array2string(a, max_line_width, precision, suppress_small, ' ', "") |
| 1735 | |
| 1736 | |
| 1737 | def _array_str_dispatcher( |
no test coverage detected
searching dependent graphs…