diff options
| author | Allan Haldane <allan.haldane@gmail.com> | 2017-11-17 21:48:38 -0500 |
|---|---|---|
| committer | Allan Haldane <allan.haldane@gmail.com> | 2017-11-17 22:53:41 -0500 |
| commit | 47a12f148cd481af89a199f33ba3106a21dc53ae (patch) | |
| tree | afc04945267dc3d5063403285642bea45026550b | |
| parent | dfc11649961a49bcce8f16c662efc16eec3855cb (diff) | |
| download | numpy-47a12f148cd481af89a199f33ba3106a21dc53ae.tar.gz | |
MAINT: add back in errstate ignore in FloatingFormat
| -rw-r--r-- | numpy/core/arrayprint.py | 7 | ||||
| -rw-r--r-- | numpy/core/tests/test_arrayprint.py | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index 0030e0ef1..9174328bf 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -721,9 +721,10 @@ class FloatingFormat(object): if len(abs_non_zero) != 0: max_val = np.max(abs_non_zero) min_val = np.min(abs_non_zero) - if max_val >= 1.e8 or (not self.suppress_small and - (min_val < 0.0001 or max_val/min_val > 1000.)): - self.exp_format = True + with errstate(over='ignore'): # division can overflow + if max_val >= 1.e8 or (not self.suppress_small and + (min_val < 0.0001 or max_val/min_val > 1000.)): + self.exp_format = True # do a first pass of printing all the numbers, to determine sizes if len(finite_vals) == 0: diff --git a/numpy/core/tests/test_arrayprint.py b/numpy/core/tests/test_arrayprint.py index 67387957d..39de1b970 100644 --- a/numpy/core/tests/test_arrayprint.py +++ b/numpy/core/tests/test_arrayprint.py @@ -354,6 +354,11 @@ class TestPrintOptions(object): assert_raises(TypeError, np.set_printoptions, wrongarg=True) + def test_float_overflow_nowarn(self): + # make sure internal computations in FloatingFormat don't + # warn about overflow + repr(np.array([1e4, 0.1], dtype='f2')) + def test_sign_spacing_structured(self): a = np.ones(2, dtype='f,f') assert_equal(repr(a), "array([(1., 1.), (1., 1.)],\n" |
