Skip to content

Commit

Permalink
TST: Test the positivity constraint for dictionary learning.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakirkham committed Feb 18, 2016
1 parent 9ab1866 commit fc931aa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sklearn/decomposition/tests/test_dict_learning.py
Expand Up @@ -38,8 +38,9 @@ def test_dict_learning_positivity():
n_components = 5
dico = DictionaryLearning(
n_components, transform_algorithm='lasso_lars', random_state=0,
transform_positive=True).fit(X)
transform_positive=True, fit_positive=True).fit(X)
code = dico.transform(X)
assert_true((dico.components_ >= 0).all())
assert_true((code >= 0).all())


Expand Down Expand Up @@ -126,13 +127,16 @@ def test_dict_learning_online_positivity():

dico = MiniBatchDictionaryLearning(
n_components, transform_algorithm='lasso_lars', random_state=0,
transform_positive=True).fit(X)
transform_positive=True, fit_positive=True).fit(X)
code = dico.transform(X)
assert_true((dico.components_ >= 0).all())
assert_true((code >= 0).all())

code, dictionary = dict_learning_online(X, n_components=n_components,
alpha=1, random_state=rng,
dict_positive=True,
code_positive=True)
assert_true((dictionary >= 0).all())
assert_true((code >= 0).all())


Expand Down

0 comments on commit fc931aa

Please sign in to comment.