Skip to content

Commit 7cb3ba1

Browse files
committed
TST: Added tests to test Deprecation warning
1 parent e915fcc commit 7cb3ba1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

sklearn/linear_model/coordinate_descent.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ def fit(self, X, y):
712712
"estimator", stacklevel=2)
713713

714714
if self.precompute == 'auto':
715-
warnings.warn("Setting precompute to 'auto', has found to be "
715+
warnings.warn("Setting precompute to 'auto', was found to be "
716716
"slower even when n_samples > n_features. Hence "
717717
"it will be removed in 0.18.",
718718
DeprecationWarning, stacklevel=2)
@@ -1217,6 +1217,7 @@ def fit(self, X, y):
12171217
model.alpha = best_alpha
12181218
model.l1_ratio = best_l1_ratio
12191219
model.copy_X = copy_X
1220+
model.precompute = False
12201221
model.fit(X, y)
12211222
if not hasattr(self, 'l1_ratio'):
12221223
del self.l1_ratio_

sklearn/linear_model/tests/test_coordinate_descent.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,18 @@ def test_random_descent():
562562
assert_raises(ValueError, clf_random.fit, X, y)
563563

564564

565+
def test_deprection_precompute_enet():
566+
"""
567+
Test that setting precompute="auto" gives a Deprecation Warning.
568+
"""
569+
570+
X, y, _, _ = build_dataset(n_samples=20, n_features=10)
571+
clf = ElasticNet(precompute="auto")
572+
assert_warns(DeprecationWarning, clf.fit, X, y)
573+
clf = Lasso(precompute="auto")
574+
assert_warns(DeprecationWarning, clf.fit, X, y)
575+
576+
565577
if __name__ == '__main__':
566578
import nose
567579
nose.runmodule()

0 commit comments

Comments
 (0)