Skip to content

Commit 03d28ee

Browse files
pprettGaelVaroquaux
authored andcommitted
added failing test for clone
1 parent 326e4f6 commit 03d28ee

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sklearn/linear_model/tests/test_sgd.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from sklearn import preprocessing
99
from sklearn.linear_model import SGDClassifier, SGDRegressor
1010
from sklearn.utils.testing import assert_greater, assert_less
11+
from sklearn.base import clone
1112

1213
import unittest
1314
from nose.tools import raises
@@ -152,6 +153,18 @@ def test_input_format(self):
152153
Y_ = np.c_[Y_, Y_]
153154
assert_raises(ValueError, clf.fit, X, Y_)
154155

156+
def test_clone(self):
157+
"""Test whether clone works ok. """
158+
clf = self.factory(alpha=0.01, n_iter=5, penalty='l1')
159+
clf = clone(clf)
160+
clf.set_params(penalty='l2')
161+
clf.fit(X, Y)
162+
163+
clf2 = self.factory(alpha=0.01, n_iter=5, penalty='l2')
164+
clf2.fit(X, Y)
165+
166+
assert_array_equal(clf.coef_, clf2.coef_)
167+
155168

156169
class DenseSGDClassifierTestCase(unittest.TestCase, CommonTest):
157170
"""Test suite for the dense representation variant of SGD"""

0 commit comments

Comments
 (0)