From 677f676172af9b46789327d789c5f5638e1d1ea9 Mon Sep 17 00:00:00 2001 From: Philip Hyunsu Cho Date: Thu, 22 Oct 2020 01:10:52 -0700 Subject: [PATCH] Use UserWarning for old callback, as DeprecationWarning is not visible (#6270) --- python-package/xgboost/training.py | 2 +- tests/python/test_callback.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python-package/xgboost/training.py b/python-package/xgboost/training.py index c224191ab..6b333e246 100644 --- a/python-package/xgboost/training.py +++ b/python-package/xgboost/training.py @@ -14,7 +14,7 @@ def _configure_deprecated_callbacks( verbose_eval, early_stopping_rounds, maximize, start_iteration, num_boost_round, feval, evals_result, callbacks, show_stdv, cvfolds): link = 'https://xgboost.readthedocs.io/en/latest/python/callbacks.html' - warnings.warn(f'Old style callback is deprecated. See: {link}', DeprecationWarning) + warnings.warn(f'Old style callback is deprecated. See: {link}', UserWarning) # Most of legacy advanced options becomes callbacks if early_stopping_rounds is not None: callbacks.append(callback.early_stop(early_stopping_rounds, diff --git a/tests/python/test_callback.py b/tests/python/test_callback.py index a4b37615a..2b482bb99 100644 --- a/tests/python/test_callback.py +++ b/tests/python/test_callback.py @@ -191,17 +191,17 @@ class TestCallbacks(unittest.TestCase): assert eval_errors_3[i] != eval_errors_2[i] def test_eta_decay_hist(self): - with pytest.deprecated_call(): + with pytest.warns(UserWarning): self.run_eta_decay('hist', True) self.run_eta_decay('hist', False) def test_eta_decay_approx(self): - with pytest.deprecated_call(): + with pytest.warns(UserWarning): self.run_eta_decay('approx', True) self.run_eta_decay('approx', False) def test_eta_decay_exact(self): - with pytest.deprecated_call(): + with pytest.warns(UserWarning): self.run_eta_decay('exact', True) self.run_eta_decay('exact', False)