Return a string representation of an array. Parameters ---------- a : 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 : int
(a, max_line_width=None, precision=None,
suppress_small=None, separator=' ', prefix="",
style=np._NoValue, formatter=None, threshold=None,
edgeitems=None, sign=None, floatmode=None, suffix="",
*, legacy=None)
| 560 | |
| 561 | @array_function_dispatch(_array2string_dispatcher, module='numpy') |
| 562 | def array2string(a, max_line_width=None, precision=None, |
| 563 | suppress_small=None, separator=' ', prefix="", |
| 564 | style=np._NoValue, formatter=None, threshold=None, |
| 565 | edgeitems=None, sign=None, floatmode=None, suffix="", |
| 566 | *, legacy=None): |
| 567 | """ |
| 568 | Return a string representation of an array. |
| 569 | |
| 570 | Parameters |
| 571 | ---------- |
| 572 | a : ndarray |
| 573 | Input array. |
| 574 | max_line_width : int, optional |
| 575 | Inserts newlines if text is longer than `max_line_width`. |
| 576 | Defaults to ``numpy.get_printoptions()['linewidth']``. |
| 577 | precision : int or None, optional |
| 578 | Floating point precision. |
| 579 | Defaults to ``numpy.get_printoptions()['precision']``. |
| 580 | suppress_small : bool, optional |
| 581 | Represent numbers "very close" to zero as zero; default is False. |
| 582 | Very close is defined by precision: if the precision is 8, e.g., |
| 583 | numbers smaller (in absolute value) than 5e-9 are represented as |
| 584 | zero. |
| 585 | Defaults to ``numpy.get_printoptions()['suppress']``. |
| 586 | separator : str, optional |
| 587 | Inserted between elements. |
| 588 | prefix : str, optional |
| 589 | suffix : str, optional |
| 590 | The length of the prefix and suffix strings are used to respectively |
| 591 | align and wrap the output. An array is typically printed as:: |
| 592 | |
| 593 | prefix + array2string(a) + suffix |
| 594 | |
| 595 | The output is left-padded by the length of the prefix string, and |
| 596 | wrapping is forced at the column ``max_line_width - len(suffix)``. |
| 597 | It should be noted that the content of prefix and suffix strings are |
| 598 | not included in the output. |
| 599 | style : _NoValue, optional |
| 600 | Has no effect, do not use. |
| 601 | |
| 602 | .. deprecated:: 1.14.0 |
| 603 | formatter : dict of callables, optional |
| 604 | If not None, the keys should indicate the type(s) that the respective |
| 605 | formatting function applies to. Callables should return a string. |
| 606 | Types that are not specified (by their corresponding keys) are handled |
| 607 | by the default formatters. Individual types for which a formatter |
| 608 | can be set are: |
| 609 | |
| 610 | - 'bool' |
| 611 | - 'int' |
| 612 | - 'timedelta' : a `numpy.timedelta64` |
| 613 | - 'datetime' : a `numpy.datetime64` |
| 614 | - 'float' |
| 615 | - 'longfloat' : 128-bit floats |
| 616 | - 'complexfloat' |
| 617 | - 'longcomplexfloat' : composed of two 128-bit floats |
| 618 | - 'void' : type `numpy.void` |
| 619 | - 'numpystr' : types `numpy.bytes_` and `numpy.str_` |
no test coverage detected