def test_Estimator__init__(): d = Wrapped(LogisticRegression(C=1000)) assert d._name == from_sklearn(clf1)._name with pytest.raises(ValueError): Wrapped(clf1, name='foo') with pytest.raises(TypeError): Wrapped("not an estimator")
def test_dir(): d = Wrapped(clf1) attrs = dir(d) assert 'C' in attrs
def test_getattr(): d = Wrapped(clf1) assert d.C == clf1.C with pytest.raises(AttributeError): d.not_a_real_parameter
def test_setattr(): d = Wrapped(clf1) with pytest.raises(AttributeError): d.C = 10
def test__estimator_type(): d = Wrapped(clf1) assert d._estimator_type == clf1._estimator_type
def test_clone(): d = Wrapped(clf1) d2 = clone(d) assert d.get_params() == d2.get_params() assert d._est is not d2._est
def test_repr(): d = Wrapped(clf1) res = repr(d) assert res.startswith('Wrapped')
def test_tokenize_Averaged(): c1 = Averaged(sgdc_1) c2 = Averaged(sgdc_2) assert tokenize(c1) == tokenize(c1) assert tokenize(c1) != tokenize(c2) assert tokenize(c1) != tokenize(Wrapped(sgdc_1))
def test_tokenize_Chained(): c1 = Chained(sgd1) c2 = Chained(sgd2) assert tokenize(c1) == tokenize(c1) assert tokenize(c1) != tokenize(c2) assert tokenize(c1) != tokenize(Wrapped(sgd1))