diff options
-rw-r--r-- | numpy/core/tests/test_print.py | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/numpy/core/tests/test_print.py b/numpy/core/tests/test_print.py index d216edd92..5802c2346 100644 --- a/numpy/core/tests/test_print.py +++ b/numpy/core/tests/test_print.py @@ -5,22 +5,8 @@ import locale 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)' - } - -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' +_REF = {np.inf: 'inf', -np.inf: '-inf', np.nan: 'nan'} + def check_float_type(tp): for x in [0, 1,-1, 1e20] : @@ -31,7 +17,12 @@ def check_float_type(tp): 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 @@ def check_complex_type(tp): 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 @@ def test_complex_types(): 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 @@ def _test_redirected_print(x, tp): 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: |