diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py index 30d92e9d0874..2facb481e9db 100644 --- a/numpy/core/tests/test_numeric.py +++ b/numpy/core/tests/test_numeric.py @@ -646,7 +646,7 @@ def test_floating_exceptions(self): if np.dtype(ftype).kind == 'f': # Get some extreme values for the type fi = np.finfo(ftype) - ft_tiny = fi.tiny + ft_tiny = fi.machar.tiny ft_max = fi.max ft_eps = fi.eps underflow = 'underflow' @@ -655,7 +655,7 @@ def test_floating_exceptions(self): # 'c', complex, corresponding real dtype rtype = type(ftype(0).real) fi = np.finfo(rtype) - ft_tiny = ftype(fi.tiny) + ft_tiny = ftype(fi.machar.tiny) ft_max = ftype(fi.max) ft_eps = ftype(fi.eps) # The complex types raise different exceptions diff --git a/numpy/core/tests/test_scalarmath.py b/numpy/core/tests/test_scalarmath.py index 09a734284a76..5981225c1f05 100644 --- a/numpy/core/tests/test_scalarmath.py +++ b/numpy/core/tests/test_scalarmath.py @@ -670,8 +670,10 @@ def _test_abs_func(self, absfunc, test_dtype): x = test_dtype(np.finfo(test_dtype).max) assert_equal(absfunc(x), x.real) - x = test_dtype(np.finfo(test_dtype).tiny) - assert_equal(absfunc(x), x.real) + with suppress_warnings() as sup: + sup.filter(UserWarning) + x = test_dtype(np.finfo(test_dtype).tiny) + assert_equal(absfunc(x), x.real) x = test_dtype(np.finfo(test_dtype).min) assert_equal(absfunc(x), -x.real) diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py index 9e7c9b743baf..0251f21a9899 100644 --- a/numpy/core/tests/test_ufunc.py +++ b/numpy/core/tests/test_ufunc.py @@ -12,7 +12,7 @@ from numpy.testing import ( assert_, assert_equal, assert_raises, assert_array_equal, assert_almost_equal, assert_array_almost_equal, assert_no_warnings, - assert_allclose, HAS_REFCOUNT, + assert_allclose, HAS_REFCOUNT, suppress_warnings ) from numpy.compat import pickle @@ -584,10 +584,12 @@ def test_true_divide(self): tgt = float(x)/float(y) rtol = max(np.finfo(dtout).resolution, 1e-15) # The value of tiny for double double is NaN - if not np.isnan(np.finfo(dtout).tiny): - atol = max(np.finfo(dtout).tiny, 3e-308) - else: - atol = 3e-308 + with suppress_warnings() as sup: + sup.filter(UserWarning) + if not np.isnan(np.finfo(dtout).tiny): + atol = max(np.finfo(dtout).tiny, 3e-308) + else: + atol = 3e-308 # Some test values result in invalid for float16. with np.errstate(invalid='ignore'): res = np.true_divide(x, y, dtype=dtout) @@ -601,10 +603,12 @@ def test_true_divide(self): tgt = complex(x)/complex(y) rtol = max(np.finfo(dtout).resolution, 1e-15) # The value of tiny for double double is NaN - if not np.isnan(np.finfo(dtout).tiny): - atol = max(np.finfo(dtout).tiny, 3e-308) - else: - atol = 3e-308 + with suppress_warnings() as sup: + sup.filter(UserWarning) + if not np.isnan(np.finfo(dtout).tiny): + atol = max(np.finfo(dtout).tiny, 3e-308) + else: + atol = 3e-308 res = np.true_divide(x, y, dtype=dtout) if not np.isfinite(res): continue diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py index dc3b05f43761..35d7ecbb5438 100644 --- a/numpy/core/tests/test_umath.py +++ b/numpy/core/tests/test_umath.py @@ -3448,9 +3448,11 @@ def test_nextafter_0(): for t, direction in itertools.product(np.sctypes['float'], (1, -1)): # The value of tiny for double double is NaN, so we need to pass the # assert - if not np.isnan(np.finfo(t).tiny): - tiny = np.finfo(t).tiny - assert_(0. < direction * np.nextafter(t(0), t(direction)) < tiny) + with suppress_warnings() as sup: + sup.filter(RuntimeWarning) + if not np.isnan(np.finfo(t).tiny): + tiny = np.finfo(t).tiny + assert_(0. < direction * np.nextafter(t(0), t(direction)) < tiny) assert_equal(np.nextafter(t(0), t(direction)) / t(2.1), direction * 0.0) def _test_spacing(t):