[Numpy-svn] r6247 - branches/fix_float_format/numpy/core/tests

numpy-svn@scip... numpy-svn@scip...
Mon Dec 29 22:41:40 CST 2008


Author: cdavid
Date: 2008-12-29 22:41:37 -0600 (Mon, 29 Dec 2008)
New Revision: 6247

Modified:
   branches/fix_float_format/numpy/core/tests/test_print.py
Log:
Handle 1e10 specially, as it is the limit where exp notation is shorter than decimal for single precision, but not for double (python native one).

Modified: branches/fix_float_format/numpy/core/tests/test_print.py
===================================================================
--- branches/fix_float_format/numpy/core/tests/test_print.py	2008-12-30 04:25:14 UTC (rev 6246)
+++ branches/fix_float_format/numpy/core/tests/test_print.py	2008-12-30 04:41:37 UTC (rev 6247)
@@ -6,10 +6,17 @@
 from StringIO import StringIO
 
 def check_float_type(tp):
-    for x in [0, 1,-1, 1e10, 1e20] :
+    for x in [0, 1,-1, 1e20] :
         assert_equal(str(tp(x)), str(float(x)),
                      err_msg='Failed str formatting for type %s' % tp)
 
+    if tp(1e10).itemsize > 4:
+        assert_equal(str(tp(1e10)), str(float('1e10')),
+                     err_msg='Failed str formatting for type %s' % tp)
+    else:
+        assert_equal(str(tp(1e10)), '1e+10',
+                     err_msg='Failed str formatting for type %s' % tp)
+
 def test_float_types():
     """ Check formatting.
 
@@ -38,7 +45,7 @@
         yield check_nan_inf_float, t
 
 def check_complex_type(tp):
-    for x in [0, 1,-1, 1e10, 1e20] :
+    for x in [0, 1,-1, 1e20] :
         assert_equal(str(tp(x)), str(complex(x)),
                      err_msg='Failed str formatting for type %s' % tp)
         assert_equal(str(tp(x*1j)), str(complex(x*1j)),
@@ -46,6 +53,13 @@
         assert_equal(str(tp(x + x*1j)), str(complex(x + x*1j)),
                      err_msg='Failed str formatting for type %s' % tp)
 
+    if tp(1e10).itemsize > 8:
+        assert_equal(str(tp(1e10)), str(complex(1e10)),
+                     err_msg='Failed str formatting for type %s' % tp)
+    else:
+        assert_equal(str(tp(1e10)), '(1e+10+0j)',
+                     err_msg='Failed str formatting for type %s' % tp)
+
 def test_complex_types():
     """Check formatting.
 



More information about the Numpy-svn mailing list