python: follow the default warning filters of Python (#2666)
* python: follow the default warning filters of Python https://docs.python.org/3/library/warnings.html#default-warning-filters * update tests * update tests
This commit is contained in:
parent
178517524f
commit
8d15024ac7
@ -13,8 +13,6 @@ from .training import train
|
|||||||
from .compat import (SKLEARN_INSTALLED, XGBModelBase,
|
from .compat import (SKLEARN_INSTALLED, XGBModelBase,
|
||||||
XGBClassifierBase, XGBRegressorBase, XGBLabelEncoder)
|
XGBClassifierBase, XGBRegressorBase, XGBLabelEncoder)
|
||||||
|
|
||||||
warnings.simplefilter('always', DeprecationWarning)
|
|
||||||
|
|
||||||
|
|
||||||
def _objective_decorator(func):
|
def _objective_decorator(func):
|
||||||
"""Decorate an objective function
|
"""Decorate an objective function
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import numpy as np
|
|||||||
import random
|
import random
|
||||||
import xgboost as xgb
|
import xgboost as xgb
|
||||||
import testing as tm
|
import testing as tm
|
||||||
import warnings
|
|
||||||
from nose.tools import raises
|
from nose.tools import raises
|
||||||
|
|
||||||
rng = np.random.RandomState(1994)
|
rng = np.random.RandomState(1994)
|
||||||
@ -340,14 +339,6 @@ def test_sklearn_random_state():
|
|||||||
assert clf.get_xgb_params()['seed'] == 401
|
assert clf.get_xgb_params()['seed'] == 401
|
||||||
|
|
||||||
|
|
||||||
def test_seed_deprecation():
|
|
||||||
tm._skip_if_no_sklearn()
|
|
||||||
warnings.simplefilter("always")
|
|
||||||
with warnings.catch_warnings(record=True) as w:
|
|
||||||
xgb.XGBClassifier(seed=1).get_xgb_params()
|
|
||||||
assert w[0].category == DeprecationWarning
|
|
||||||
|
|
||||||
|
|
||||||
def test_sklearn_n_jobs():
|
def test_sklearn_n_jobs():
|
||||||
tm._skip_if_no_sklearn()
|
tm._skip_if_no_sklearn()
|
||||||
|
|
||||||
@ -358,14 +349,6 @@ def test_sklearn_n_jobs():
|
|||||||
assert clf.get_xgb_params()['nthread'] == 2
|
assert clf.get_xgb_params()['nthread'] == 2
|
||||||
|
|
||||||
|
|
||||||
def test_nthread_deprecation():
|
|
||||||
tm._skip_if_no_sklearn()
|
|
||||||
warnings.simplefilter("always")
|
|
||||||
with warnings.catch_warnings(record=True) as w:
|
|
||||||
xgb.XGBClassifier(nthread=1).get_xgb_params()
|
|
||||||
assert w[0].category == DeprecationWarning
|
|
||||||
|
|
||||||
|
|
||||||
def test_kwargs():
|
def test_kwargs():
|
||||||
tm._skip_if_no_sklearn()
|
tm._skip_if_no_sklearn()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user