summaryrefslogtreecommitdiff
path: root/numpy/core/arrayprint.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core/arrayprint.py')
-rw-r--r--numpy/core/arrayprint.py27
1 files changed, 12 insertions, 15 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
index 2706d16f0..f996aa394 100644
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -416,8 +416,8 @@ def _array2string(a, options, separator=' ', prefix=""):
def array2string(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):
+ style=None, formatter=None, threshold=None,
+ edgeitems=None, sign=None):
"""
Return a string representation of an array.
@@ -441,12 +441,11 @@ def array2string(a, max_line_width=None, precision=None,
'prefix(' + array2string(a) + ')'
- The length of the prefix string is used to align the
- output correctly.
- style : _NoValue, optional
- Has no effect, do not use.
-
- .. deprecated:: 1.14.0
+ The length of the prefix string is used to align the output correctly.
+ style : None or function, optional
+ Controls the printing of 0d arrays. If `None`, prints the 0d array's
+ element using the usual array formatting. Otherwise, `style` should be
+ a function that accepts a numpy scalar and returns a string.
formatter : dict of callables, optional
If not None, the keys should indicate the type(s) that the respective
formatting function applies to. Callables should return a string.
@@ -541,18 +540,15 @@ def array2string(a, max_line_width=None, precision=None,
'[0x0L 0x1L 0x2L]'
"""
- # Deprecation 05-16-2017 v1.14
- if style is not np._NoValue:
- warnings.warn("'style' argument is deprecated and no longer functional",
- DeprecationWarning, stacklevel=3)
-
overrides = _make_options_dict(precision, threshold, edgeitems,
max_line_width, suppress_small, None, None,
sign, formatter, floatmode)
options = _format_options.copy()
options.update(overrides)
- if a.size == 0:
+ if style is not None and a.shape == ():
+ return style(a[()])
+ elif a.size == 0:
# treat as a null array if any of shape elements == 0
lst = "[]"
else:
@@ -1164,7 +1160,8 @@ def array_str(a, max_line_width=None, precision=None, suppress_small=None):
'[0 1 2]'
"""
- return array2string(a, max_line_width, precision, suppress_small, ' ', "")
+ return array2string(a, max_line_width, precision, suppress_small,
+ ' ', "", str)
def set_string_function(f, repr=True):
"""