summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_nanfunctions.py
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2016-08-31 21:16:08 +0200
committerSebastian Berg <sebastian@sipsolutions.net>2016-09-02 10:10:55 +0200
commit20ea3a25119834c2224e32caebf4f2fb4966edd3 (patch)
tree7d3ccc7506b76b1d72f96c9f097d54a2383080e8 /numpy/lib/tests/test_nanfunctions.py
parent61694be14e678ae49f35205d5af0aee4882e1a70 (diff)
downloadnumpy-20ea3a25119834c2224e32caebf4f2fb4966edd3.tar.gz
TST: Replace catch_warnings when recording is not enforced in test_nanfuncs
Diffstat (limited to 'numpy/lib/tests/test_nanfunctions.py')
-rw-r--r--numpy/lib/tests/test_nanfunctions.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/numpy/lib/tests/test_nanfunctions.py b/numpy/lib/tests/test_nanfunctions.py
index e062bc032..e4aea4482 100644
--- a/numpy/lib/tests/test_nanfunctions.py
+++ b/numpy/lib/tests/test_nanfunctions.py
@@ -167,8 +167,8 @@ class TestNanFunctions_ArgminArgmax(TestCase):
def test_result_values(self):
for f, fcmp in zip(self.nanfuncs, [np.greater, np.less]):
for row in _ndat:
- with warnings.catch_warnings(record=True):
- warnings.simplefilter('always')
+ with suppress_warnings() as sup:
+ sup.filter(RuntimeWarning, "invalid value encountered in")
ind = f(row)
val = row[ind]
# comparing with NaN is tricky as the result
@@ -589,8 +589,8 @@ class TestNanFunctions_Median(TestCase):
w = np.random.random((4, 200)) * np.array(d.shape)[:, None]
w = w.astype(np.intp)
d[tuple(w)] = np.nan
- with warnings.catch_warnings(record=True) as w:
- warnings.simplefilter('always', RuntimeWarning)
+ with suppress_warnings() as sup:
+ sup.filter(RuntimeWarning)
res = np.nanmedian(d, axis=None, keepdims=True)
assert_equal(res.shape, (1, 1, 1, 1))
res = np.nanmedian(d, axis=(0, 1), keepdims=True)
@@ -687,8 +687,8 @@ class TestNanFunctions_Median(TestCase):
assert_raises(ValueError, np.nanmedian, d, axis=(1, 1))
def test_float_special(self):
- with warnings.catch_warnings(record=True):
- warnings.simplefilter('always', RuntimeWarning)
+ with suppress_warnings() as sup:
+ sup.filter(RuntimeWarning)
a = np.array([[np.inf, np.nan], [np.nan, np.nan]])
assert_equal(np.nanmedian(a, axis=0), [np.inf, np.nan])
assert_equal(np.nanmedian(a, axis=1), [np.inf, np.nan])
@@ -725,8 +725,8 @@ class TestNanFunctions_Percentile(TestCase):
w = np.random.random((4, 200)) * np.array(d.shape)[:, None]
w = w.astype(np.intp)
d[tuple(w)] = np.nan
- with warnings.catch_warnings(record=True) as w:
- warnings.simplefilter('always', RuntimeWarning)
+ with suppress_warnings() as sup:
+ sup.filter(RuntimeWarning)
res = np.nanpercentile(d, 90, axis=None, keepdims=True)
assert_equal(res.shape, (1, 1, 1, 1))
res = np.nanpercentile(d, 90, axis=(0, 1), keepdims=True)
@@ -821,8 +821,8 @@ class TestNanFunctions_Percentile(TestCase):
large_mat[:, :, 3:] *= 2
for axis in [None, 0, 1]:
for keepdim in [False, True]:
- with warnings.catch_warnings(record=True) as w:
- warnings.simplefilter('always')
+ with suppress_warnings() as sup:
+ sup.filter(RuntimeWarning, "All-NaN slice encountered")
val = np.percentile(mat, perc, axis=axis, keepdims=keepdim)
nan_val = np.nanpercentile(nan_mat, perc, axis=axis,
keepdims=keepdim)