diff options
author | Allan Haldane <allan.haldane@gmail.com> | 2017-09-14 10:58:15 -0400 |
---|---|---|
committer | Allan Haldane <allan.haldane@gmail.com> | 2017-09-25 14:10:50 -0400 |
commit | 2ecae5ee158b9600c207b4c42e2ed531c8f385e9 (patch) | |
tree | 338a89c29af4624e0ba2039b548f27f7f4b5e251 /numpy/core/arrayprint.py | |
parent | f7be36b05feff7f54b3e118a9af265d0b9de94e2 (diff) | |
download | numpy-2ecae5ee158b9600c207b4c42e2ed531c8f385e9.tar.gz |
MAINT: rework recursive guard to keep array2string signature
Diffstat (limited to 'numpy/core/arrayprint.py')
-rw-r--r-- | numpy/core/arrayprint.py | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index 795ceec6c..cdcf94007 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -349,30 +349,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='...'): """ @@ -403,9 +379,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): @@ -503,7 +503,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", |