diff options
author | David Cournapeau <cournape@gmail.com> | 2008-12-30 04:49:31 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2008-12-30 04:49:31 +0000 |
commit | 31b6cdf83b48b7f6d7ee86f341bf7ed47b6d4a29 (patch) | |
tree | 0cb18d4afd44a9fe5553a03fe60a6226883ecf8c /numpy | |
parent | 3e0e21c68d2df22ff73e98205b144266764a9412 (diff) | |
download | numpy-31b6cdf83b48b7f6d7ee86f341bf7ed47b6d4a29.tar.gz |
Fix test for single precision print.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/tests/test_print.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/numpy/core/tests/test_print.py b/numpy/core/tests/test_print.py index 442a5a73c..efdd9b0d5 100644 --- a/numpy/core/tests/test_print.py +++ b/numpy/core/tests/test_print.py @@ -88,16 +88,30 @@ def _test_redirected_print(x, tp): err_msg='print failed for type%s' % tp) def check_float_type_print(tp): - for x in [0, 1,-1, 1e10, 1e20, 'inf', 'nan', '-inf'] : + for x in [0, 1,-1, 1e20, 'inf', 'nan', '-inf'] : _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, 1e10, 1e20, complex(float('inf'), 1), + for x in [0, 1, -1, 1e20, complex(float('inf'), 1), complex(float('nan'), 1), complex(float('-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] : |