Skip to content

Commit 3579a87

Browse files
ogrisellarsmans
authored andcommitted
PY3: record is a kwarg argument for warnings.catch_warnings
1 parent b556759 commit 3579a87

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

sklearn/metrics/tests/test_metrics.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,14 @@ def test_roc_curve_one_label():
188188
y_true = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
189189
y_pred = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]
190190
# assert there are warnings
191-
with warnings.catch_warnings(True) as w:
191+
with warnings.catch_warnings(record=True) as w:
192192
fpr, tpr, thresholds = roc_curve(y_true, y_pred)
193193
assert_equal(len(w), 1)
194194
# all true labels, all fpr should be nan
195195
assert_array_equal(fpr,
196196
np.nan * np.ones(len(thresholds) + 1))
197197
# assert there are warnings
198-
with warnings.catch_warnings(True) as w:
198+
with warnings.catch_warnings(record=True) as w:
199199
fpr, tpr, thresholds = roc_curve([1 - x for x in y_true],
200200
y_pred)
201201
assert_equal(len(w), 1)
@@ -568,7 +568,7 @@ def test_losses():
568568

569569
# Classification
570570
# --------------
571-
with warnings.catch_warnings(True):
571+
with warnings.catch_warnings(record=True):
572572
# Throw deprecated warning
573573
assert_equal(zero_one(y_true, y_pred), 13)
574574
assert_almost_equal(zero_one(y_true, y_pred, normalize=True),
@@ -589,7 +589,7 @@ def test_losses():
589589
assert_equal(accuracy_score(y_true, y_pred, normalize=False),
590590
n_samples - zero_one_loss(y_true, y_pred, normalize=False))
591591

592-
with warnings.catch_warnings(True):
592+
with warnings.catch_warnings(record=True):
593593
# Throw deprecated warning
594594
assert_equal(zero_one_score(y_true, y_pred),
595595
1 - zero_one_loss(y_true, y_pred))
@@ -661,7 +661,7 @@ def test_symmetry():
661661
msg="%s seems to be symetric" % metric)
662662

663663
# Deprecated metrics
664-
with warnings.catch_warnings(True):
664+
with warnings.catch_warnings(record=True):
665665
# Throw deprecated warning
666666
assert_equal(zero_one(y_true, y_pred),
667667
zero_one(y_pred, y_true))

sklearn/tests/test_cross_validation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def score_func(y_test, y_predict):
291291
_score_func_args.append((y_test, y_predict))
292292
return 1.0
293293

294-
with warnings.catch_warnings(True):
294+
with warnings.catch_warnings(record=True):
295295
score = cval.cross_val_score(clf, X, y, score_func=score_func)
296296
assert_array_equal(score, [1.0, 1.0, 1.0])
297297
assert len(_score_func_args) == 3
@@ -381,7 +381,7 @@ def test_cross_val_score_with_score_func_regression():
381381
assert_array_almost_equal(mse_scores, expected_mse, 2)
382382

383383
# Explained variance
384-
with warnings.catch_warnings(True):
384+
with warnings.catch_warnings(record=True):
385385
ev_scores = cval.cross_val_score(reg, X, y, cv=5,
386386
score_func=explained_variance_score)
387387
assert_array_almost_equal(ev_scores, [0.94, 0.97, 0.97, 0.99, 0.92], 2)

0 commit comments

Comments
 (0)