Return the string representation of an array. Parameters ---------- arr : ndarray Input array. max_line_width : int, optional Inserts newlines if text is longer than `max_line_width`. Defaults to ``numpy.get_printoptions()['linewidth']``. precision :
(arr, max_line_width=None, precision=None, suppress_small=None)
| 1659 | |
| 1660 | @array_function_dispatch(_array_repr_dispatcher, module='numpy') |
| 1661 | def array_repr(arr, max_line_width=None, precision=None, suppress_small=None): |
| 1662 | """ |
| 1663 | Return the string representation of an array. |
| 1664 | |
| 1665 | Parameters |
| 1666 | ---------- |
| 1667 | arr : ndarray |
| 1668 | Input array. |
| 1669 | max_line_width : int, optional |
| 1670 | Inserts newlines if text is longer than `max_line_width`. |
| 1671 | Defaults to ``numpy.get_printoptions()['linewidth']``. |
| 1672 | precision : int, optional |
| 1673 | Floating point precision. |
| 1674 | Defaults to ``numpy.get_printoptions()['precision']``. |
| 1675 | suppress_small : bool, optional |
| 1676 | Represent numbers "very close" to zero as zero; default is False. |
| 1677 | Very close is defined by precision: if the precision is 8, e.g., |
| 1678 | numbers smaller (in absolute value) than 5e-9 are represented as |
| 1679 | zero. |
| 1680 | Defaults to ``numpy.get_printoptions()['suppress']``. |
| 1681 | |
| 1682 | Returns |
| 1683 | ------- |
| 1684 | string : str |
| 1685 | The string representation of an array. |
| 1686 | |
| 1687 | See Also |
| 1688 | -------- |
| 1689 | array_str, array2string, set_printoptions |
| 1690 | |
| 1691 | Examples |
| 1692 | -------- |
| 1693 | >>> import numpy as np |
| 1694 | >>> np.array_repr(np.array([1,2])) |
| 1695 | 'array([1, 2])' |
| 1696 | >>> np.array_repr(np.ma.array([0.])) |
| 1697 | 'MaskedArray([0.])' |
| 1698 | >>> np.array_repr(np.array([], np.int32)) |
| 1699 | 'array([], dtype=int32)' |
| 1700 | |
| 1701 | >>> x = np.array([1e-6, 4e-7, 2, 3]) |
| 1702 | >>> np.array_repr(x, precision=6, suppress_small=True) |
| 1703 | 'array([0.000001, 0. , 2. , 3. ])' |
| 1704 | |
| 1705 | """ |
| 1706 | return _array_repr_implementation( |
| 1707 | arr, max_line_width, precision, suppress_small) |
| 1708 | |
| 1709 | |
| 1710 | @_recursive_guard() |
nothing calls this directly
no test coverage detected
searching dependent graphs…