summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/arrayprint.py7
-rw-r--r--numpy/core/tests/test_arrayprint.py2
2 files changed, 5 insertions, 4 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
index aad80dd7a..472318098 100644
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -879,8 +879,7 @@ class FloatingFormat(object):
for x in finite_vals)
int_part, frac_part = zip(*(s.split('.') for s in strs))
if self._legacy == '1.13':
- self.pad_left = 1 + max(len(s.lstrip('-').lstrip('+'))
- for s in int_part)
+ self.pad_left = 1 + max(len(s.lstrip('-+')) for s in int_part)
else:
self.pad_left = max(len(s) for s in int_part)
self.pad_right = max(len(s) for s in frac_part)
@@ -896,8 +895,8 @@ class FloatingFormat(object):
if self._legacy != '1.13':
# account for sign = ' ' by adding one to pad_left
- if all(finite_vals >= 0) and self.sign == ' ':
- self.pad_left += 1
+ if self.sign == ' ' and not any(np.signbit(finite_vals)):
+ self.pad_left += 1
# if there are non-finite values, may need to increase pad_left
if data.size != finite_vals.size:
diff --git a/numpy/core/tests/test_arrayprint.py b/numpy/core/tests/test_arrayprint.py
index 81e74442b..e63801bba 100644
--- a/numpy/core/tests/test_arrayprint.py
+++ b/numpy/core/tests/test_arrayprint.py
@@ -441,6 +441,7 @@ class TestPrintOptions(object):
assert_equal(repr(np.array([0.])), 'array([0.])')
assert_equal(repr(c),
"array([1. +1.j , 1.12345679+1.12345679j])")
+ assert_equal(repr(np.array([0., -0.])), 'array([ 0., -0.])')
np.set_printoptions(sign=' ')
assert_equal(repr(a), 'array([ 0., 1., 2., 3.])')
@@ -448,6 +449,7 @@ class TestPrintOptions(object):
assert_equal(repr(b), 'array([ 1.234e+09])')
assert_equal(repr(c),
"array([ 1. +1.j , 1.12345679+1.12345679j])")
+ assert_equal(repr(np.array([0., -0.])), 'array([ 0., -0.])')
np.set_printoptions(sign='+')
assert_equal(repr(a), 'array([+0., +1., +2., +3.])')