예제 #1
0
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")
예제 #2
0
def test_dir():
    d = Wrapped(clf1)
    attrs = dir(d)
    assert 'C' in attrs
예제 #3
0
def test_getattr():
    d = Wrapped(clf1)
    assert d.C == clf1.C
    with pytest.raises(AttributeError):
        d.not_a_real_parameter
예제 #4
0
def test_setattr():
    d = Wrapped(clf1)
    with pytest.raises(AttributeError):
        d.C = 10
예제 #5
0
def test__estimator_type():
    d = Wrapped(clf1)
    assert d._estimator_type == clf1._estimator_type
예제 #6
0
def test_clone():
    d = Wrapped(clf1)
    d2 = clone(d)
    assert d.get_params() == d2.get_params()
    assert d._est is not d2._est
예제 #7
0
def test_repr():
    d = Wrapped(clf1)
    res = repr(d)
    assert res.startswith('Wrapped')
예제 #8
0
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))
예제 #9
0
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))