Skip to content

Commit

Permalink
TST: Add tests and document whats_new.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
MechCoder committed Oct 16, 2014
1 parent 5e1faef commit 13c2b00
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ API changes summary
``precompute="auto"`` is now deprecated and will be removed in 0.18
By `Manoj Kumar`_.

- Expose ``positive`` option in :func:`linear_model.enet_path` and
:func:`linear_model.enet_path` which constrains coefficients to be
positive. By `Manoj Kumar`_.

.. _changes_0_15_2:

0.15.2
Expand Down
13 changes: 12 additions & 1 deletion sklearn/linear_model/tests/test_coordinate_descent.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from sklearn.linear_model.coordinate_descent import Lasso, \
LassoCV, ElasticNet, ElasticNetCV, MultiTaskLasso, MultiTaskElasticNet, \
MultiTaskElasticNetCV, MultiTaskLassoCV, lasso_path
MultiTaskElasticNetCV, MultiTaskLassoCV, lasso_path, enet_path
from sklearn.linear_model import LassoLarsCV, lars_path


Expand Down Expand Up @@ -574,6 +574,17 @@ def test_deprection_precompute_enet():
assert_warns(DeprecationWarning, clf.fit, X, y)


def test_enet_path_positive():
"""
Test that the coefs returned by positive=True in enet_path are positive
"""

X, y, _, _ = build_dataset(n_samples=50, n_features=50)
for path in [enet_path, lasso_path]:
pos_path_coef = path(X, y, positive=True)[1]
assert_true(np.all(pos_path_coef >= 0))


if __name__ == '__main__':
import nose
nose.runmodule()

0 comments on commit 13c2b00

Please sign in to comment.