Use UserWarning for old callback, as DeprecationWarning is not visible (#6270)

This commit is contained in:
Philip Hyunsu Cho 2020-10-22 01:10:52 -07:00 committed by GitHub
parent 1300467d36
commit 677f676172
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -14,7 +14,7 @@ def _configure_deprecated_callbacks(
verbose_eval, early_stopping_rounds, maximize, start_iteration, verbose_eval, early_stopping_rounds, maximize, start_iteration,
num_boost_round, feval, evals_result, callbacks, show_stdv, cvfolds): num_boost_round, feval, evals_result, callbacks, show_stdv, cvfolds):
link = 'https://xgboost.readthedocs.io/en/latest/python/callbacks.html' 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 # Most of legacy advanced options becomes callbacks
if early_stopping_rounds is not None: if early_stopping_rounds is not None:
callbacks.append(callback.early_stop(early_stopping_rounds, callbacks.append(callback.early_stop(early_stopping_rounds,

View File

@ -191,17 +191,17 @@ class TestCallbacks(unittest.TestCase):
assert eval_errors_3[i] != eval_errors_2[i] assert eval_errors_3[i] != eval_errors_2[i]
def test_eta_decay_hist(self): 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', True)
self.run_eta_decay('hist', False) self.run_eta_decay('hist', False)
def test_eta_decay_approx(self): 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', True)
self.run_eta_decay('approx', False) self.run_eta_decay('approx', False)
def test_eta_decay_exact(self): 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', True)
self.run_eta_decay('exact', False) self.run_eta_decay('exact', False)