def test_dataflow_evaluation_no_input_two_outputs(): df = DataFlow() vid = df.add_vertex() pid0 = df.add_out_port(vid, "out1") df.set_actor(vid, FuncNode({}, {}, double_fixed_function)) dfs = DataflowState(df) env = 0 algo = BruteEvaluation(df) algo.eval(env, dfs, vid) assert tuple(dfs.get_data(pid0)) == (5, 5) algo.clear() dfs.reinit() pid1 = df.add_out_port(vid, "out2") algo.eval(env, dfs, vid) assert dfs.get_data(pid0) == 5 assert dfs.get_data(pid1) == 5 algo.clear() dfs.reinit() pid2 = df.add_out_port(vid, "out3") assert_raises(UserWarning, lambda: algo.eval(env, dfs, vid))
def test_dataflow_evaluation_eval_no_vid(): df, (pid_in, pid_out) = get_dataflow() algo = BruteEvaluation(df) env = 0 dfs = DataflowState(df) dfs.set_data(pid_in, 1) assert not dfs.is_valid() algo.eval(env, dfs) assert dfs.is_valid()
def test_dataflow_evaluation_eval_init(): df, (pid_in, pid_out) = get_dataflow() algo = BruteEvaluation(df) env = 0 dfs = DataflowState(df) assert_raises(UserWarning, lambda: algo.eval(env, dfs))
def test_dataflow_evaluation_single_input_single_output(): df = DataFlow() vid = df.add_vertex() pid0 = df.add_in_port(vid, "in") pid1 = df.add_in_port(vid, "in") pid2 = df.add_out_port(vid, "out") df.set_actor(vid, FuncNode({}, {}, operator.add)) dfs = DataflowState(df) env = 0 algo = BruteEvaluation(df) dfs.set_data(pid0, 1) dfs.set_data(pid1, 2) algo.eval(env, dfs, vid) assert dfs.get_data(pid0) == 1 assert dfs.get_data(pid1) == 2 assert dfs.get_data(pid2) == 3
def test_dataflow_evaluation_single_input_no_output(): df = DataFlow() vid = df.add_vertex() pid0 = df.add_in_port(vid, "in") df.set_actor(vid, FuncNode({}, {}, print)) dfs = DataflowState(df) env = 0 algo = BruteEvaluation(df) dfs.set_data(pid0, 1) algo.eval(env, dfs, vid) assert dfs.get_data(pid0) == 1 df.set_actor(vid, FuncNode({}, {}, int)) dfs.reinit() algo.clear() assert_raises(UserWarning, lambda: algo.eval(env, dfs, vid))
def test_dataflow_evaluation_single_input_no_output(): df = DataFlow() vid = df.add_vertex() pid0 = df.add_in_port(vid, "in") df.set_actor(vid, FuncNode({}, {}, print_func)) dfs = DataflowState(df) env = 0 algo = BruteEvaluation(df) dfs.set_data(pid0, 1) algo.eval(env, dfs, vid) assert dfs.get_data(pid0) == 1 df.set_actor(vid, FuncNode({}, {}, int)) dfs.reinit() algo.clear() assert_raises(UserWarning, lambda: algo.eval(env, dfs, vid))
def test_dataflow_evaluation_eval_no_vid2(): df = DataFlow() vid0 = df.add_vertex() pid0 = df.add_in_port(vid0, "in") df.add_out_port(vid0, "out") vid1 = df.add_vertex() pid1 = df.add_in_port(vid1, "in") df.add_out_port(vid1, "out") df.set_actor(vid0, FuncNode({}, {}, int)) df.set_actor(vid1, FuncNode({}, {}, int)) dfs = DataflowState(df) env = 0 algo = BruteEvaluation(df) dfs.set_data(pid0, 0) dfs.set_data(pid1, 1) assert not dfs.is_valid() algo.eval(env, dfs) assert dfs.is_valid()