|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
| 3 | +import logging |
3 | 4 | import re |
4 | 5 | from typing import Any, Optional, Tuple |
5 | 6 |
|
@@ -228,22 +229,24 @@ def test_valid_verbose(verbose: Any) -> None: |
228 | 229 | check_verbose(verbose) |
229 | 230 |
|
230 | 231 |
|
231 | | -def test_initial_low_high_pred() -> None: |
| 232 | +def test_initial_low_high_pred(caplog) -> None: |
232 | 233 | """Test lower/upper predictions of the quantiles regression crossing""" |
233 | 234 | y_preds = np.array([[4, 5, 2], [4, 4, 4], [2, 3, 4]]) |
234 | | - with pytest.warns(UserWarning, match=r"WARNING: The predictions are*"): |
| 235 | + with caplog.at_level(logging.INFO): |
235 | 236 | check_lower_upper_bounds(y_preds[0], y_preds[1], y_preds[2]) |
| 237 | + assert "The predictions are ill-sorted" in caplog.text |
236 | 238 |
|
237 | 239 |
|
238 | | -def test_final_low_high_pred() -> None: |
| 240 | +def test_final_low_high_pred(caplog) -> None: |
239 | 241 | """Test lower/upper predictions crossing""" |
240 | 242 | y_preds = np.array( |
241 | 243 | [[4, 3, 2], [3, 3, 3], [2, 3, 4]] |
242 | 244 | ) |
243 | 245 | y_pred_low = np.array([4, 7, 2]) |
244 | 246 | y_pred_up = np.array([3, 3, 3]) |
245 | | - with pytest.warns(UserWarning, match=r"WARNING: The predictions are*"): |
| 247 | + with caplog.at_level(logging.INFO): |
246 | 248 | check_lower_upper_bounds(y_pred_low, y_pred_up, y_preds[2]) |
| 249 | + assert "The predictions are ill-sorted" in caplog.text |
247 | 250 |
|
248 | 251 |
|
249 | 252 | def test_ensemble_in_predict() -> None: |
@@ -331,19 +334,6 @@ def test_quantile_prefit_non_iterable(estimator: Any) -> None: |
331 | 334 | mapie_reg.fit([1, 2, 3], [4, 5, 6]) |
332 | 335 |
|
333 | 336 |
|
334 | | -# def test_calib_set_no_Xy_but_sample_weight() -> None: |
335 | | -# """Test warning message if sample weight provided but no X y in calib.""" |
336 | | -# X = np.array([4, 5, 6]) |
337 | | -# y = np.array([4, 3, 2]) |
338 | | -# sample_weight = np.array([4, 4, 4]) |
339 | | -# sample_weight_calib = np.array([4, 3, 4]) |
340 | | -# with pytest.warns(UserWarning, match=r"WARNING: sample weight*"): |
341 | | -# check_calib_set( |
342 | | -# X=X, y=y, sample_weight=sample_weight, |
343 | | -# sample_weight_calib=sample_weight_calib |
344 | | -# ) |
345 | | - |
346 | | - |
347 | 337 | @pytest.mark.parametrize("strategy", ["quantile", "uniform", "array split"]) |
348 | 338 | def test_binning_group_strategies(strategy: str) -> None: |
349 | 339 | """Test that different strategies have the correct outputs.""" |
|
0 commit comments