[Numpy-svn] r6262 - in branches/fix_float_format: . numpy/core/tests

numpy-svn at scipy.org numpy-svn at scipy.org
Tue Dec 30 00:54:37 EST 2008


Author: cdavid
Date: 2008-12-29 23:54:33 -0600 (Mon, 29 Dec 2008)
New Revision: 6262

Modified:
   branches/fix_float_format/
   branches/fix_float_format/numpy/core/tests/test_print.py
Log:
Merged revisions 6260-6261 via svnmerge from 
http://svn.scipy.org/svn/numpy/trunk

........
  r6260 | cdavid | 2008-12-30 14:50:18 +0900 (Tue, 30 Dec 2008) | 1 line
  
  Fix more formatting tests on win32.
........
  r6261 | cdavid | 2008-12-30 14:52:16 +0900 (Tue, 30 Dec 2008) | 1 line
  
  Fix some more redirected output print tests.
........



Property changes on: branches/fix_float_format
___________________________________________________________________
Name: svnmerge-integrated
   - /branches/distutils-revamp:1-2752 /branches/dynamic_cpu_configuration:1-6101 /branches/multicore:1-3687 /branches/numpy-mingw-w64:1-6150 /branches/visualstudio_manifest:1-6077 /trunk:1-6244,6251,6253,6256,6258
   + /branches/distutils-revamp:1-2752 /branches/dynamic_cpu_configuration:1-6101 /branches/multicore:1-3687 /branches/numpy-mingw-w64:1-6150 /branches/visualstudio_manifest:1-6077 /trunk:1-6244,6251,6253,6256,6258,6260-6261

Modified: branches/fix_float_format/numpy/core/tests/test_print.py
===================================================================
--- branches/fix_float_format/numpy/core/tests/test_print.py	2008-12-30 05:52:16 UTC (rev 6261)
+++ branches/fix_float_format/numpy/core/tests/test_print.py	2008-12-30 05:54:33 UTC (rev 6262)
@@ -9,6 +9,11 @@
         '(inf+1j)', complex(np.nan, 1): '(nan+1j)', complex(-np.inf, 1):
         '(-inf+1j)'}
 
+if sys.platform == 'win32' and sys.version_info[0] <= 2 and sys.version_info[1] <= 5:
+    _REF[np.float32(1e10)] = '1e+010'
+else:
+    _REF[np.float32(1e10)] = '1e+10'
+
 def check_float_type(tp):
     for x in [0, 1,-1, 1e20] :
         assert_equal(str(tp(x)), str(float(x)),
@@ -18,11 +23,7 @@
         assert_equal(str(tp(1e10)), str(float('1e10')),
                      err_msg='Failed str formatting for type %s' % tp)
     else:
-        if sys.platform == 'win32' and sys.version_info[0] <= 2 and sys.version_info[1] <= 5:
-            ref = '1e+010'
-        else:
-            ref = '1e+10'
-        assert_equal(str(tp(1e10)), ref,
+        assert_equal(str(tp(1e10)), _REF[tp(1e10)],
                      err_msg='Failed str formatting for type %s' % tp)
 
 def test_float_types():
@@ -65,11 +66,7 @@
         assert_equal(str(tp(1e10)), str(complex(1e10)),
                      err_msg='Failed str formatting for type %s' % tp)
     else:
-        if sys.platform == 'win32' and sys.version_info[0] <= 2 and sys.version_info[1] <= 5:
-            ref = '(1e+010+0j)'
-        else:
-            ref = '(1e+10+0j)'
-        assert_equal(str(tp(1e10)), ref,
+        assert_equal(str(tp(1e10)), _REF[tp(1e10)],
                      err_msg='Failed str formatting for type %s' % tp)
 
 def test_complex_types():
@@ -103,30 +100,16 @@
                  err_msg='print failed for type%s' % tp)
 
 def check_float_type_print(tp):
-    for x in [0, 1,-1, 1e20, np.inf, -np.inf, np.nan]:
+    for x in [0, 1,-1, 1e10, 1e20, np.inf, -np.inf, np.nan]:
         _test_redirected_print(float(x), 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 check_complex_type_print(tp):
     # We do not create complex with inf/nan directly because the feature is
     # missing in python < 2.6
-    for x in [0, 1, -1, 1e20, complex(np.inf, 1),
+    for x in [0, 1, -1, 1e10, 1e20, complex(np.inf, 1),
               complex(np.nan, 1), complex(-np.inf, 1)] :
         _test_redirected_print(complex(x), 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_float_type_print():
     """Check formatting when using print """
     for t in [np.float32, np.double, np.longdouble] :




More information about the Numpy-svn mailing list