示例#1
0
def test_dump(resource_tmp_file):
    # synonym of save
    p = Pipe() +\
        Segment(lambda x: x+1, "step1") + \
        Segment(lambda x: x+1, "step2")

    p._dump(resource_tmp_file)
示例#2
0
def test_sklearn_pipe_fit_predict1():
    p = Pipe() +\
        Segment(anova_filter, 'anova') +\
        Segment(clf, 'svc')

    p.fit(X, y)
    p.predict(X)
示例#3
0
def test_load_save_utility_funcs(resource_tmp_file):
    from mlpipe.utils import save, load
    p = Pipe() +\
        Segment(lambda x: x+1, "step1") + \
        Segment(lambda x: x+1, "step2")

    save(p, resource_tmp_file)
    load(resource_tmp_file)
示例#4
0
def test_save_fitted_load_predict(resource_tmp_file):
    p = Pipe() +\
        Segment(anova_filter, 'anova') +\
        Segment(clf, 'svc')

    p.fit(X, y)
    p._save(resource_tmp_file)
    p = Pipe._load(resource_tmp_file)
    p.predict(X)
示例#5
0
def test_sklearn_pipe_serialize():
    def dummy(*args):
        return args

    p = Pipe() +\
        Segment(anova_filter, 'anova') +\
        Segment(dummy) +\
        Segment(clf, 'svc')

    p.fit(X, y)
    p.predict(X, y=None)
示例#6
0
def test_no_input():
    p = Pipe() +\
        Segment(lambda *_: 2)

    p2 = Pipe() + \
        Segment(lambda *_: 2) + \
        Segment(lambda x: x)

    assert p() == 2
    assert p(5) == 2

    assert p2() == 2
    assert p2(5) == 2
示例#7
0
def test_kwargs2():
    p = Pipe() +\
        Segment(my_func, description="test", b=1) +\
        Segment(my_func, description="test", b=2)

    assert p(1) == 4
    assert p.bla(1) == 4


# def test_args():
#     p = Pipe() +\
#         Segment(my_func, description="test", 1)
#
#     assert p(1) == 2
示例#8
0
def test_save(resource_tmp_file):
    p = Pipe() +\
        Segment(lambda x: x+1, "step1") + \
        Segment(lambda x: x+1, "step2")

    p._save(resource_tmp_file)
示例#9
0
def test_dumps():
    p = Pipe() +\
        Segment(lambda x: x+1, "step1") + \
        Segment(lambda x: x+1, "step2")

    p._dumps()
示例#10
0
def test_lambda1_wo_attr():
    p = Pipe() +\
        Segment(lambda x: x+2)

    assert p(5) == 7
示例#11
0
def test_lambda2_w_attr():
    p = Pipe() +\
        Segment(lambda x: x+2) + \
        Segment(lambda x: x + 2)

    assert p.testattr(5) == 9
示例#12
0
def test_kwargs():
    p = Pipe() + Segment(my_func, b=1)

    assert p(1) == 2
    assert p.bla(1) == 2