TST Replace pytest.warns(None) in test_gpc.py
# Modified by: Pete Green <p.l.green@liverpool.ac.uk>
# License: BSD 3 clause
+import warnings
import sys
import re
import numpy as np
@@ -478,10 +479,13 @@ def test_warning_bounds():
length_scale_bounds=[1e3, 1e5]
)
gpr_sum = GaussianProcessRegressor(kernel=kernel_sum)
- with pytest.warns(None) as record:
+ with warnings.catch_warnings(record=True) as record:
+ warnings.simplefilter("always")
gpr_sum.fit(X, y)
assert len(record) == 2
+
+ assert issubclass(record[0].category, ConvergenceWarning)
assert (
record[0].message.args[0]
== "The optimal value found for "
@@ -492,6 +496,7 @@ def test_warning_bounds():
"fit again may find a better value."
)
+ assert issubclass(record[1].category, ConvergenceWarning)
assert (
record[1].message.args[0]
== "The optimal value found for "
@@ -506,10 +511,13 @@ def test_warning_bounds():
kernel_dims = RBF(length_scale=[1.0, 2.0], length_scale_bounds=[1e1, 1e2])
gpr_dims = GaussianProcessRegressor(kernel=kernel_dims)
- with pytest.warns(None) as record:
+ with warnings.catch_warnings(record=True) as record:
+ warnings.simplefilter("always")
gpr_dims.fit(X_tile, y)
assert len(record) == 2
+
+ assert issubclass(record[0].category, ConvergenceWarning)
assert (
record[0].message.args[0]
== "The optimal value found for "
@@ -520,6 +528,7 @@ def test_warning_bounds():
"fit again may find a better value."
)
+ assert issubclass(record[1].category, ConvergenceWarning)
assert (
record[1].message.args[0]
== "The optimal value found for "
