diff options
author | rgommers <ralf.gommers@googlemail.com> | 2010-11-08 21:11:49 +0800 |
---|---|---|
committer | rgommers <ralf.gommers@googlemail.com> | 2010-11-08 21:11:49 +0800 |
commit | cb8ebd26f05524725bb16037bf07af3be839b0e4 (patch) | |
tree | e49d257f7070d712632fc506d7f9a064331d2a9e | |
parent | 435c7262592e94c8519f4288a19035de054758fd (diff) | |
download | numpy-cb8ebd26f05524725bb16037bf07af3be839b0e4.tar.gz |
TST: silence ldexp overflow warning.
-rw-r--r-- | numpy/core/tests/test_umath.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py index 3f2601150..40b78fdb5 100644 --- a/numpy/core/tests/test_umath.py +++ b/numpy/core/tests/test_umath.py @@ -401,10 +401,15 @@ class TestLdexp(TestCase): "python.org < 2.6 binaries have broken ldexp in the " "C runtime") def test_ldexp_overflow(self): - imax = np.iinfo(np.dtype('l')).max - imin = np.iinfo(np.dtype('l')).min - assert_equal(ncu.ldexp(2., imax), np.inf) - assert_equal(ncu.ldexp(2., imin), 0) + # silence warning emitted on overflow + err = np.seterr(over="ignore") + try: + imax = np.iinfo(np.dtype('l')).max + imin = np.iinfo(np.dtype('l')).min + assert_equal(ncu.ldexp(2., imax), np.inf) + assert_equal(ncu.ldexp(2., imin), 0) + finally: + np.seterr(**err) class TestMaximum(TestCase): @@ -644,7 +649,7 @@ class TestSpecialMethods(TestCase): class with_prepare(np.ndarray): __array_priority__ = 10 def __array_prepare__(self, arr, context): - # make sure we can return a new + # make sure we can return a new return np.array(arr).view(type=with_prepare) a = np.array(1).view(type=with_prepare) x = np.add(a, a) @@ -1082,16 +1087,16 @@ def test_reduceat(): h2 = np.array(h2) # test buffered -- this should work - h1 = np.add.reduceat(a['value'], indx) + h1 = np.add.reduceat(a['value'], indx) assert_array_almost_equal(h1, h2) # This is when the error occurs. # test no buffer res = np.setbufsize(32) h1 = np.add.reduceat(a['value'], indx) - np.setbufsize(np.UFUNC_BUFSIZE_DEFAULT) + np.setbufsize(np.UFUNC_BUFSIZE_DEFAULT) assert_array_almost_equal(h1, h2) - + def test_complex_nan_comparisons(): nans = [complex(np.nan, 0), complex(0, np.nan), complex(np.nan, np.nan)] |