summaryrefslogtreecommitdiff
path: root/numpy/core/arrayprint.py
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2017-09-25 18:01:13 -0700
committerGitHub <noreply@github.com>2017-09-25 18:01:13 -0700
commitceef499596981071b359b41718c65ac5f959ee87 (patch)
treeaae4da011e9c9cb4083bfd4714ed55b5ab160aa6 /numpy/core/arrayprint.py
parentbac743beff16d596363e0f7ad4570a7a6bfe7fe5 (diff)
parent2ecae5ee158b9600c207b4c42e2ed531c8f385e9 (diff)
downloadnumpy-ceef499596981071b359b41718c65ac5f959ee87.tar.gz
Merge pull request #9688 from ahaldane/array2string_sig
MAINT: rework recursive guard to keep array2string signature
Diffstat (limited to 'numpy/core/arrayprint.py')
-rw-r--r--numpy/core/arrayprint.py53
1 files changed, 26 insertions, 27 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
index b8e60562f..33d08cdd0 100644
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -355,30 +355,6 @@ def _get_format_function(data, precision, suppress_small, formatter):
else:
return formatdict['numpystr']()
-def _array2string(a, max_line_width, precision, suppress_small, separator=' ',
- prefix="", formatter=None):
-
- if a.size > _summaryThreshold:
- summary_insert = "..., "
- data = _leading_trailing(a)
- else:
- summary_insert = ""
- data = ravel(asarray(a))
-
- # find the right formatting function for the array
- format_function = _get_format_function(data, precision,
- suppress_small, formatter)
-
- # skip over "["
- next_line_prefix = " "
- # skip over array(
- next_line_prefix += " "*len(prefix)
-
- lst = _formatArray(a, format_function, a.ndim, max_line_width,
- next_line_prefix, separator,
- _summaryEdgeItems, summary_insert)[:-1]
- return lst
-
def _recursive_guard(fillvalue='...'):
"""
@@ -409,9 +385,33 @@ def _recursive_guard(fillvalue='...'):
return decorating_function
-# gracefully handle recursive calls - this comes up when object arrays contain
-# themselves
+# gracefully handle recursive calls, when object arrays contain themselves
@_recursive_guard()
+def _array2string(a, max_line_width, precision, suppress_small, separator=' ',
+ prefix="", formatter=None):
+
+ if a.size > _summaryThreshold:
+ summary_insert = "..., "
+ data = _leading_trailing(a)
+ else:
+ summary_insert = ""
+ data = ravel(asarray(a))
+
+ # find the right formatting function for the array
+ format_function = _get_format_function(data, precision,
+ suppress_small, formatter)
+
+ # skip over "["
+ next_line_prefix = " "
+ # skip over array(
+ next_line_prefix += " "*len(prefix)
+
+ lst = _formatArray(a, format_function, a.ndim, max_line_width,
+ next_line_prefix, separator,
+ _summaryEdgeItems, summary_insert)[:-1]
+ return lst
+
+
def array2string(a, max_line_width=None, precision=None,
suppress_small=None, separator=' ', prefix="",
style=np._NoValue, formatter=None):
@@ -509,7 +509,6 @@ 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",