[Numpy-svn] r6258 - trunk/numpy/core/tests

numpy-svn@scip... numpy-svn@scip...
Mon Dec 29 23:42:07 CST 2008


Author: cdavid
Date: 2008-12-29 23:42:03 -0600 (Mon, 29 Dec 2008)
New Revision: 6258

Modified:
   trunk/numpy/core/tests/test_print.py
Log:
Hardcode reference for inf/nan-involved values.

Modified: trunk/numpy/core/tests/test_print.py
===================================================================
--- trunk/numpy/core/tests/test_print.py	2008-12-30 05:36:00 UTC (rev 6257)
+++ trunk/numpy/core/tests/test_print.py	2008-12-30 05:42:03 UTC (rev 6258)
@@ -5,6 +5,10 @@
 import sys
 from StringIO import StringIO
 
+_REF = {np.inf: 'inf', -np.inf: '-inf', np.nan: 'nan', complex(np.inf, 1):
+        '(inf+1j)', complex(np.nan, 1): '(nan+1j)', complex(-np.inf, 1):
+        '(-inf+1j)'}
+
 def check_float_type(tp):
     for x in [0, 1,-1, 1e20] :
         assert_equal(str(tp(x)), str(float(x)),
@@ -34,7 +38,7 @@
 
 def check_nan_inf_float(tp):
     for x in [np.inf, -np.inf, np.nan]:
-        assert_equal(str(tp(x)), str(float(x)),
+        assert_equal(str(tp(x)), _REF[x],
                      err_msg='Failed str formatting for type %s' % tp)
 
 def test_nan_inf_float():
@@ -88,7 +92,10 @@
         sys.stdout = file_tp
         print tp(x)
         sys.stdout = file
-        print x
+        if x in _REF:
+            print _REF[x]
+        else:
+            print x
     finally:
         sys.stdout = stdout
 



More information about the Numpy-svn mailing list