summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2018-04-24 16:18:02 -0600
committerGitHub <noreply@github.com>2018-04-24 16:18:02 -0600
commit4b40612dde5f4b4ec6def2eacc5e8ab2d838806d (patch)
treeba00576c063b50b413e80deb447b74b4fbfa8010
parentcfa022f7a02e0e8362cbeb21c2e951d2c6066af5 (diff)
parenta280b7c47586bebf4e1baff6ec604c4713ef1097 (diff)
downloadnumpy-4b40612dde5f4b4ec6def2eacc5e8ab2d838806d.tar.gz
Merge pull request #10947 from ahaldane/fix_style_arg_1.14
BUG: 'style' arg to array2string broken in legacy mode (1.14 Backport)
-rw-r--r--numpy/core/arrayprint.py3
-rw-r--r--numpy/core/tests/test_arrayprint.py2
2 files changed, 5 insertions, 0 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
index ad0d05c42..4f29d7565 100644
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -612,6 +612,9 @@ def array2string(a, max_line_width=None, precision=None,
options.update(overrides)
if options['legacy'] == '1.13':
+ if style is np._NoValue:
+ style = repr
+
if a.shape == () and not a.dtype.names:
return style(a.item())
elif style is not np._NoValue:
diff --git a/numpy/core/tests/test_arrayprint.py b/numpy/core/tests/test_arrayprint.py
index 050e6f296..40a99e169 100644
--- a/numpy/core/tests/test_arrayprint.py
+++ b/numpy/core/tests/test_arrayprint.py
@@ -488,6 +488,8 @@ class TestPrintOptions(object):
np.array(1.), style=repr)
# but not in legacy mode
np.array2string(np.array(1.), style=repr, legacy='1.13')
+ # gh-10934 style was broken in legacy mode, check it works
+ np.array2string(np.array(1.), legacy='1.13')
def test_float_spacing(self):
x = np.array([1., 2., 3.])