summaryrefslogtreecommitdiff
path: root/numpy/core/arrayprint.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2010-02-21 16:16:34 +0000
committerCharles Harris <charlesr.harris@gmail.com>2010-02-21 16:16:34 +0000
commit52c43da079009c4b18ec5a7ac6bf31ef6cad69ed (patch)
treeb05f3facb76ce508d3305c0b61d0c335c6dc4987 /numpy/core/arrayprint.py
parent93b41a2f6082ee7293c45c7538d898369e158a61 (diff)
downloadnumpy-52c43da079009c4b18ec5a7ac6bf31ef6cad69ed.tar.gz
BUG: Work around warning raised by np.isinf(np.inf). The isinf warning should be fixed at a
lower level and tested separately. In the meantime, this fix avoids a lot of irrelevant warning messages in the tests.
Diffstat (limited to 'numpy/core/arrayprint.py')
-rw-r--r--numpy/core/arrayprint.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
index 2367f76e1..934d08dc8 100644
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -18,6 +18,7 @@ from umath import maximum, minimum, absolute, not_equal, isnan, isinf
from multiarray import format_longfloat
from fromnumeric import ravel
+
def product(x, y): return x*y
_summaryEdgeItems = 3 # repr N leading and trailing items of each dimension
@@ -412,6 +413,7 @@ class FloatFormat(object):
self.exp_format = True
finally:
_nc.seterr(**errstate)
+
if self.exp_format:
self.large_exponent = 0 < min_val < 1e-99 or max_val >= 1e100
self.max_str_len = 8 + self.precision
@@ -444,13 +446,19 @@ class FloatFormat(object):
self.format = format
def __call__(self, x, strip_zeros=True):
- if isnan(x):
- return self.special_fmt % (_nan_str,)
- elif isinf(x):
- if x > 0:
- return self.special_fmt % (_inf_str,)
- else:
- return self.special_fmt % ('-' + _inf_str,)
+ import numeric as _nc
+ err = _nc.seterr(invalid='ignore')
+ try:
+ if isnan(x):
+ return self.special_fmt % (_nan_str,)
+ elif isinf(x):
+ if x > 0:
+ return self.special_fmt % (_inf_str,)
+ else:
+ return self.special_fmt % ('-' + _inf_str,)
+ finally:
+ _nc.seterr(**err)
+
s = self.format % x
if self.large_exponent:
# 3-digit exponent