[Numpy-svn] r8244 - trunk/numpy/core

numpy-svn@scip... numpy-svn@scip...
Sun Feb 21 10:16:34 CST 2010


Author: charris
Date: 2010-02-21 10:16:34 -0600 (Sun, 21 Feb 2010)
New Revision: 8244

Modified:
   trunk/numpy/core/arrayprint.py
Log:
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.

Modified: trunk/numpy/core/arrayprint.py
===================================================================
--- trunk/numpy/core/arrayprint.py	2010-02-21 16:16:29 UTC (rev 8243)
+++ trunk/numpy/core/arrayprint.py	2010-02-21 16:16:34 UTC (rev 8244)
@@ -18,6 +18,7 @@
 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 @@
                     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 @@
         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



More information about the Numpy-svn mailing list