summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Cournapeau <cournape@gmail.com>2008-12-30 06:35:00 +0000
committerDavid Cournapeau <cournape@gmail.com>2008-12-30 06:35:00 +0000
commitd7b5be19940936c10ed1ed45879d6aef56cb55a6 (patch)
tree09d1eb41d6f5afcfa74015adefe7e64326d2ec0c
parentcebec2247bd9c1d459e1722f8da9e42009851660 (diff)
parente69b591fe458d0efda7fdaef4194358dfd6a0872 (diff)
downloadnumpy-d7b5be19940936c10ed1ed45879d6aef56cb55a6.tar.gz
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. ........
-rw-r--r--numpy/core/tests/test_print.py38
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: