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

numpy-svn@scip... numpy-svn@scip...
Tue Dec 30 00:35:08 CST 2008


Author: cdavid
Date: 2008-12-30 00:35:00 -0600 (Tue, 30 Dec 2008)
New Revision: 6272

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

........
  r6271 | cdavid | 2008-12-30 15:32:03 +0900 (Tue, 30 Dec 2008) | 1 line
  
  Do not use dict for reference: hashing on scalar arrays does not work as I expected.
........



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-6269
   + /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-6271

Modified: branches/fix_float_format/numpy/core/tests/test_print.py
===================================================================
--- branches/fix_float_format/numpy/core/tests/test_print.py	2008-12-30 06:32:03 UTC (rev 6271)
+++ branches/fix_float_format/numpy/core/tests/test_print.py	2008-12-30 06:35:00 UTC (rev 6272)
@@ -5,22 +5,8 @@
 import sys
 from StringIO import StringIO
 
-_REF = {np.inf: 'inf', -np.inf: '-inf', np.nan: 'nan',
-        np.complex64(complex(np.inf, 1)): '(inf+1j)',
-        np.complex64(complex(np.nan, 1)): '(nan+1j)',
-        np.complex64(complex(-np.inf, 1)): '(-inf+1j)',
-        np.cdouble(complex(np.inf, 1)): '(inf+1j)',
-        np.cdouble(complex(np.nan, 1)): '(nan+1j)',
-        np.cdouble(complex(-np.inf, 1)): '(-inf+1j)',
-        np.clongdouble(complex(np.inf, 1)): '(inf+1j)',
-        np.clongdouble(complex(np.nan, 1)): '(nan+1j)',
-        np.clongdouble(complex(-np.inf, 1)): '(-inf+1j)'
-        }
+_REF = {np.inf: 'inf', -np.inf: '-inf', np.nan: 'nan'}
 
-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] :
@@ -31,7 +17,12 @@
         assert_equal(str(tp(1e10)), str(float('1e10')),
                      err_msg='Failed str formatting for type %s' % tp)
     else:
-        assert_equal(str(tp(1e10)), _REF[tp(1e10)],
+        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,
                      err_msg='Failed str formatting for type %s' % tp)
 
 def test_float_types():
@@ -74,7 +65,12 @@
         assert_equal(str(tp(1e10)), str(complex(1e10)),
                      err_msg='Failed str formatting for type %s' % tp)
     else:
-        assert_equal(str(tp(1e10)), _REF[tp(1e10)],
+        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,
                      err_msg='Failed str formatting for type %s' % tp)
 
 def test_complex_types():
@@ -89,7 +85,7 @@
         yield check_complex_type, t
 
 # print tests
-def _test_redirected_print(x, tp):
+def _test_redirected_print(x, tp, ref=None):
     file = StringIO()
     file_tp = StringIO()
     stdout = sys.stdout
@@ -97,8 +93,8 @@
         sys.stdout = file_tp
         print tp(x)
         sys.stdout = file
-        if tp(x) in _REF:
-            print _REF[tp(x)]
+        if ref:
+            print ref
         else:
             print x
     finally:



More information about the Numpy-svn mailing list