Skip to content

Commit 47f0c20

Browse files
committed
Added tests and fixed flake8
1 parent fc5c880 commit 47f0c20

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

sklearn/linear_model/__init__.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# See http://scikit-learn.sourceforge.net/modules/sgd.html and
99
# http://scikit-learn.sourceforge.net/modules/linear_model.html for
1010
# complete documentation.
11-
import warnings
11+
1212
from .base import LinearRegression
1313

1414
from .bayes import BayesianRidge, ARDRegression
@@ -31,11 +31,6 @@
3131
from .passive_aggressive import PassiveAggressiveRegressor
3232
from .perceptron import Perceptron
3333

34-
with warnings.catch_warnings():
35-
warnings.simplefilter('ignore')
36-
from .randomized_l1 import (RandomizedLasso, RandomizedLogisticRegression,
37-
lasso_stability_path)
38-
3934
from .ransac import RANSACRegressor
4035
from .theil_sen import TheilSenRegressor
4136

sklearn/linear_model/tests/test_randomized_l1.py

+30-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from sklearn.utils.testing import assert_raises_regex
1313
from sklearn.utils.testing import assert_allclose
1414
from sklearn.utils.testing import ignore_warnings
15+
from sklearn.utils.testing import assert_warns_message
1516

16-
import warnings
1717
from sklearn.linear_model.randomized_l1 import(lasso_stability_path,
1818
RandomizedLasso,
1919
RandomizedLogisticRegression)
@@ -32,6 +32,7 @@
3232
# test that the feature score of the best features
3333
F, _ = f_regression(X, y)
3434

35+
3536
@ignore_warnings(category=DeprecationWarning)
3637
def test_lasso_stability_path():
3738
# Check lasso stability path
@@ -186,3 +187,31 @@ def test_randomized_logistic_sparse():
186187
tol=1e-3)
187188
feature_scores_sp = clf.fit(X_sp, y).scores_
188189
assert_array_equal(feature_scores, feature_scores_sp)
190+
191+
192+
def test_warning_raised():
193+
194+
scaling = 0.3
195+
selection_threshold = 0.5
196+
tempdir = 5
197+
assert_warns_message(DeprecationWarning, "The function"
198+
" lasso_stability_path is "
199+
"deprecated in 0.19 and will be removed in 0.21.",
200+
lasso_stability_path, X, y, scaling=scaling,
201+
random_state=42, n_resampling=30)
202+
203+
assert_warns_message(DeprecationWarning, "The class"
204+
" RandomizedLasso is "
205+
"deprecated in 0.19 and will be removed in 0.21.",
206+
RandomizedLasso, verbose=False, alpha=[1, 0.8],
207+
random_state=42, scaling=scaling,
208+
selection_threshold=selection_threshold,
209+
memory=tempdir)
210+
211+
assert_warns_message(DeprecationWarning, "The function"
212+
" log_multivariate_normal_density is "
213+
"deprecated in 0.19 and will be removed in 0.21.",
214+
RandomizedLogisticRegression,
215+
verbose=False, C=1., random_state=42,
216+
scaling=scaling, n_resampling=50,
217+
tol=1e-3)

0 commit comments

Comments
 (0)