MCPcopy Create free account
hub / github.com/numpy/numpy / array2string

Function array2string

numpy/core/arrayprint.py:562–736  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

560
561@array_function_dispatch(_array2string_dispatcher, module='numpy')
562def 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_`

Callers 3

assert_array_compareFunction · 0.90

Calls 6

_make_options_dictFunction · 0.85
_array2stringFunction · 0.85
updateMethod · 0.80
itemMethod · 0.80
warnMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected