Skip to content

Commit c6037e7

Browse files
committed
Ensure that n_nonzero_coefs is an int
1 parent 36acda2 commit c6037e7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sklearn/decomposition/dict_learning.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@ def _sparse_encode(X, dictionary, gram, cov=None, algorithm='lasso_lars',
146146

147147
elif algorithm == 'omp':
148148
# TODO: Should verbose argument be passed to this?
149-
new_code = orthogonal_mp_gram(gram, cov, regularization, None,
150-
row_norms(X, squared=True),
151-
copy_Xy=copy_cov).T
149+
new_code = orthogonal_mp_gram(
150+
Gram=gram, Xy=cov, n_nonzero_coefs=int(regularization),
151+
tol=None, norms_squared=row_norms(X, squared=True),
152+
copy_Xy=copy_cov).T
152153
else:
153154
raise ValueError('Sparse coding method must be "lasso_lars" '
154155
'"lasso_cd", "lasso", "threshold" or "omp", got %s.'

0 commit comments

Comments
 (0)