Skip to content

Commit 7cfe756

Browse files
committed
Check deprecation message in SparsePCA test
1 parent 442c404 commit 7cfe756

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

sklearn/decomposition/tests/test_sparse_pca.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from sklearn.utils.testing import SkipTest
1212
from sklearn.utils.testing import assert_true
1313
from sklearn.utils.testing import assert_false
14-
from sklearn.utils.testing import assert_warns
14+
from sklearn.utils.testing import assert_warns_message
1515
from sklearn.utils.testing import if_safe_multiprocessing_with_blas
1616

1717
from sklearn.decomposition import SparsePCA, MiniBatchSparsePCA
@@ -72,8 +72,11 @@ def test_fit_transform():
7272
assert_array_almost_equal(spca_lasso.components_, spca_lars.components_)
7373

7474
# Test that deprecated ridge_alpha parameter throws warning
75-
assert_warns(DeprecationWarning, spca_lars.transform, Y, ridge_alpha=0.01)
76-
assert_warns(DeprecationWarning, spca_lars.transform, Y, ridge_alpha=None)
75+
warning_msg = "The ridge_alpha parameter on transform()"
76+
assert_warns_message(DeprecationWarning, warning_msg, spca_lars.transform,
77+
Y, ridge_alpha=0.01)
78+
assert_warns_message(DeprecationWarning, warning_msg, spca_lars.transform,
79+
Y, ridge_alpha=None)
7780

7881

7982
@if_safe_multiprocessing_with_blas

0 commit comments

Comments
 (0)