Skip to content

Commit 156a1f3

Browse files
amuellerogrisel
authored andcommitted
remove modification of warning registry for no reason (scikit-learn#9569)
1 parent 279833e commit 156a1f3

File tree

2 files changed

+1
-42
lines changed

2 files changed

+1
-42
lines changed

sklearn/base.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -225,21 +225,7 @@ def get_params(self, deep=True):
225225
"""
226226
out = dict()
227227
for key in self._get_param_names():
228-
# We need deprecation warnings to always be on in order to
229-
# catch deprecated param values.
230-
# This is set in utils/__init__.py but it gets overwritten
231-
# when running under python3 somehow.
232-
warnings.simplefilter("always", DeprecationWarning)
233-
try:
234-
with warnings.catch_warnings(record=True) as w:
235-
value = getattr(self, key, None)
236-
if len(w) and w[0].category == DeprecationWarning:
237-
# if the parameter is deprecated, don't show it
238-
continue
239-
finally:
240-
warnings.filters.pop(0)
241-
242-
# XXX: should we rather test if instance of estimator?
228+
value = getattr(self, key, None)
243229
if deep and hasattr(value, 'get_params'):
244230
deep_items = value.get_params().items()
245231
out.update((key + '__' + k, val) for k, val in deep_items)
@@ -316,7 +302,6 @@ def __setstate__(self, state):
316302
self.__dict__.update(state)
317303

318304

319-
320305
###############################################################################
321306
class ClassifierMixin(object):
322307
"""Mixin class for all classifiers in scikit-learn."""

sklearn/tests/test_base.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,6 @@ def __init__(self, a=np.array([0])):
6161
self.a = a.copy()
6262

6363

64-
class DeprecatedAttributeEstimator(BaseEstimator):
65-
def __init__(self, a=None, b=None):
66-
self.a = a
67-
if b is not None:
68-
DeprecationWarning("b is deprecated and renamed 'a'")
69-
self.a = b
70-
71-
@property
72-
@deprecated("Parameter 'b' is deprecated and renamed to 'a'")
73-
def b(self):
74-
return self._b
75-
76-
7764
class Buggy(BaseEstimator):
7865
" A buggy estimator that does not set its parameters right. "
7966

@@ -219,19 +206,6 @@ def test_get_params():
219206
assert_raises(ValueError, test.set_params, a__a=2)
220207

221208

222-
def test_get_params_deprecated():
223-
# deprecated attribute should not show up as params
224-
est = DeprecatedAttributeEstimator(a=1)
225-
226-
assert_true('a' in est.get_params())
227-
assert_true('a' in est.get_params(deep=True))
228-
assert_true('a' in est.get_params(deep=False))
229-
230-
assert_true('b' not in est.get_params())
231-
assert_true('b' not in est.get_params(deep=True))
232-
assert_true('b' not in est.get_params(deep=False))
233-
234-
235209
def test_is_classifier():
236210
svc = SVC()
237211
assert_true(is_classifier(svc))

0 commit comments

Comments
 (0)