10000 [MRG+1] BUG: fix svd_solver validation in PCA.fit (#8496) · Sundrique/scikit-learn@6d75dd7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6d75dd7

Browse files
jakevdpSundrique
authored andcommitted
[MRG+1] BUG: fix svd_solver validation in PCA.fit (scikit-learn#8496)
* BUG: fix svd_solver validation in PCA.fit * TST: add test of pca svd_solver
1 parent 332ea29 commit 6d75dd7

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

sklearn/decomposition/pca.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@ def _fit(self, X):
386386
return self._fit_full(X, n_components)
387387
elif svd_solver in ['arpack', 'randomized']:
388388
return self._fit_truncated(X, n_components, svd_solver)
389+
else:
390+
raise ValueError("Unrecognized svd_solver='{0}'"
391+
"".format(svd_solver))
389392

390393
def _fit_full(self, X, n_components):
391394
"""Fit the model by computing full SVD on X"""

sklearn/decomposition/tests/test_pca.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,3 +584,9 @@ def test_pca_spase_input():
584584
pca = PCA(n_components=3, svd_solver=svd_solver)
585585

586586
assert_raises(TypeError, pca.fit, X)
587+
588+
589+
def test_pca_bad_solver():
590+
X = np.random.RandomState(0).rand(5, 4)
591+
pca = PCA(n_components=3, svd_solver='bad_argument')
592+
assert_raises(ValueError, pca.fit, X)

0 commit comments

Comments
 (0)
0