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="",
*, formatter=None, threshold=None,
edgeitems=None, sign=None, floatmode=None, suffix="",
legacy=None)
| 642 | |
| 643 | @array_function_dispatch(_array2string_dispatcher, module='numpy') |
| 644 | def array2string(a, max_line_width=None, precision=None, |
| 645 | suppress_small=None, separator=' ', prefix="", |
| 646 | *, formatter=None, threshold=None, |
| 647 | edgeitems=None, sign=None, floatmode=None, suffix="", |
| 648 | legacy=None): |
| 649 | """ |
| 650 | Return a string representation of an array. |
| 651 | |
| 652 | Parameters |
| 653 | ---------- |
| 654 | a : ndarray |
| 655 | Input array. |
| 656 | max_line_width : int, optional |
| 657 | Inserts newlines if text is longer than `max_line_width`. |
| 658 | Defaults to ``numpy.get_printoptions()['linewidth']``. |
| 659 | precision : int or None, optional |
| 660 | Floating point precision. |
| 661 | Defaults to ``numpy.get_printoptions()['precision']``. |
| 662 | suppress_small : bool, optional |
| 663 | Represent numbers "very close" to zero as zero; default is False. |
| 664 | Very close is defined by precision: if the precision is 8, e.g., |
| 665 | numbers smaller (in absolute value) than 5e-9 are represented as |
| 666 | zero. |
| 667 | Defaults to ``numpy.get_printoptions()['suppress']``. |
| 668 | separator : str, optional |
| 669 | Inserted between elements. |
| 670 | prefix : str, optional |
| 671 | suffix : str, optional |
| 672 | The length of the prefix and suffix strings are used to respectively |
| 673 | align and wrap the output. An array is typically printed as:: |
| 674 | |
| 675 | prefix + array2string(a) + suffix |
| 676 | |
| 677 | The output is left-padded by the length of the prefix string, and |
| 678 | wrapping is forced at the column ``max_line_width - len(suffix)``. |
| 679 | It should be noted that the content of prefix and suffix strings are |
| 680 | not included in the output. |
| 681 | formatter : dict of callables, optional |
| 682 | If not None, the keys should indicate the type(s) that the respective |
| 683 | formatting function applies to. Callables should return a string. |
| 684 | Types that are not specified (by their corresponding keys) are handled |
| 685 | by the default formatters. Individual types for which a formatter |
| 686 | can be set are: |
| 687 | |
| 688 | - 'bool' |
| 689 | - 'int' |
| 690 | - 'timedelta' : a `numpy.timedelta64` |
| 691 | - 'datetime' : a `numpy.datetime64` |
| 692 | - 'float' |
| 693 | - 'longfloat' : 128-bit floats |
| 694 | - 'complexfloat' |
| 695 | - 'longcomplexfloat' : composed of two 128-bit floats |
| 696 | - 'void' : type `numpy.void` |
| 697 | - 'numpystr' : types `numpy.bytes_` and `numpy.str_` |
| 698 | |
| 699 | Other keys that can be used to set a group of types at once are: |
| 700 | |
| 701 | - 'all' : sets all types |
no test coverage detected
searching dependent graphs…