Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dd85748

Browse files
committed
Merge pull request #4342 from seberg/issue-4340
TST: do not use "ignore" to filter warnings
2 parents 34d7bee + fd399aa commit dd85748

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

numpy/lib/tests/test_function_base.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,8 +1222,8 @@ def test_xy(self):
12221222
assert_allclose(np.corrcoef(x, y), np.array([[1., -1.j], [1.j, 1.]]))
12231223

12241224
def test_empty(self):
1225-
with warnings.catch_warnings():
1226-
warnings.simplefilter('ignore', RuntimeWarning)
1225+
with warnings.catch_warnings(record=True):
1226+
warnings.simplefilter('always', RuntimeWarning)
12271227
assert_array_equal(corrcoef(np.array([])), np.nan)
12281228
assert_array_equal(corrcoef(np.array([]).reshape(0, 2)),
12291229
np.array([]).reshape(0, 0))
@@ -1232,8 +1232,8 @@ def test_empty(self):
12321232

12331233
def test_wrong_ddof(self):
12341234
x = np.array([[0, 2], [1, 1], [2, 0]]).T
1235-
with warnings.catch_warnings():
1236-
warnings.simplefilter('ignore', RuntimeWarning)
1235+
with warnings.catch_warnings(record=True):
1236+
warnings.simplefilter('always', RuntimeWarning)
12371237
assert_array_equal(corrcoef(x, ddof=5),
12381238
np.array([[np.nan, np.nan], [np.nan, np.nan]]))
12391239

@@ -1253,8 +1253,8 @@ def test_xy(self):
12531253
assert_allclose(cov(x, y), np.array([[1., -1.j], [1.j, 1.]]))
12541254

12551255
def test_empty(self):
1256-
with warnings.catch_warnings():
1257-
warnings.simplefilter('ignore', RuntimeWarning)
1256+
with warnings.catch_warnings(record=True):
1257+
warnings.simplefilter('always', RuntimeWarning)
12581258
assert_array_equal(cov(np.array([])), np.nan)
12591259
assert_array_equal(cov(np.array([]).reshape(0, 2)),
12601260
np.array([]).reshape(0, 0))
@@ -1263,8 +1263,8 @@ def test_empty(self):
12631263

12641264
def test_wrong_ddof(self):
12651265
x = np.array([[0, 2], [1, 1], [2, 0]]).T
1266-
with warnings.catch_warnings():
1267-
warnings.simplefilter('ignore', RuntimeWarning)
1266+
with warnings.catch_warnings(record=True):
1267+
warnings.simplefilter('always', RuntimeWarning)
12681268
assert_array_equal(cov(x, ddof=5),
12691269
np.array([[np.inf, -np.inf], [-np.inf, np.inf]]))
12701270

numpy/lib/tests/test_nanfunctions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ def test_mutation(self):
130130
def test_result_values(self):
131131
for f, fcmp in zip(self.nanfuncs, [np.greater, np.less]):
132132
for row in _ndat:
133-
with warnings.catch_warnings():
134-
warnings.simplefilter('ignore')
133+
with warnings.catch_warnings(record=True):
134+
warnings.simplefilter('always')
135135
ind = f(row)
136136
val = row[ind]
137137
# comparing with NaN is tricky as the result

0 commit comments

Comments
 (0)