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)
def test_sklearn_pipe_fit_predict1(): p = Pipe() +\ Segment(anova_filter, 'anova') +\ Segment(clf, 'svc') p.fit(X, y) p.predict(X)
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)
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)
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)
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
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
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)
def test_dumps(): p = Pipe() +\ Segment(lambda x: x+1, "step1") + \ Segment(lambda x: x+1, "step2") p._dumps()
def test_lambda1_wo_attr(): p = Pipe() +\ Segment(lambda x: x+2) assert p(5) == 7
def test_lambda2_w_attr(): p = Pipe() +\ Segment(lambda x: x+2) + \ Segment(lambda x: x + 2) assert p.testattr(5) == 9
def test_kwargs(): p = Pipe() + Segment(my_func, b=1) assert p(1) == 2 assert p.bla(1) == 2