def test_CStar_1(): def custom(input): return [1, 2, 3] bf = sf.Formation() bf.add(CStar(custom)) assert bf.run("test")[0] == [1, 2, 3]
def test_run_3(): # Same as multicore_1 but many many layers bf = sf.Formation() input = sf.Star() bf.add(input) attach_to_star(input, 10) outputs = bf.mp_run(1, 4) assert bf.run(1) == bf.run(1, 4)
def test_run_2(): # Test multi processing # MultiProcess can be slower from overhead(add is fast) bf = sf.Formation() input = sf.Star() bf.add(input) attach_to_star(input, 1) outputs = bf.mp_run(1, 4) assert outputs == [3, 1, 1, -1]
def test_run_2(): # test multicore with star progressing into 2 stars running multiprocess # * # | | <- split into 2 # * * bf = sf.Formation() input = sf.Star() bf.add(input) input.link(CStar(custom)) input.link(sf.Star()) outputs = bf.mp_run("test", 4) assert outputs[0] == [1, 2, 3] assert outputs[1] == "test"
def test_bind_2(): # Check if bind() works bf = sf.Formation() bf.add(sf.Star().bind(1)) bf.add(sf.Star()) assert bf.run()[0] == 1
def test_run_1(): # test single star bf = sf.Formation() bs = sf.Star() bf.add(bs) assert bf.run("test")[0] == "test"
def test_CStar_2(): # test 2 stars bf = sf.Formation() bf.add(sf.Star()) bf.add(CStar(lambda x: [1, 2, 3])) assert bf.run("test")[0] == [1, 2, 3]
def test_bind_3(): # Check if bind() works bf = sf.Formation() bf.add(sf.Star().bind([1, 2, 3])) bf.add(sf.Star()) assert bf.run()[0] == [1, 2, 3]
def test_multicore_2(): tradeF = sf.Formation() tradeF.add(CStar(yf.download).bind("AAPL")) assert len(tradeF.run())