当前位置: 首页>>代码示例>>Python>>正文


Python port_graph.PortGraph类代码示例

本文整理汇总了Python中openalea.workflow.port_graph.PortGraph的典型用法代码示例。如果您正苦于以下问题:Python PortGraph类的具体用法?Python PortGraph怎么用?Python PortGraph使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PortGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_ws_can_not_store_data_on_input_port

def test_ws_can_not_store_data_on_input_port():
    pg = PortGraph()
    pg.add_vertex(0)
    pg.add_in_port(0, "in", 0)
    ws = WorkflowState(pg)

    assert_raises(UserWarning, lambda: ws.store(0, "data"))
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:7,代码来源:test_state.py

示例2: test_ws_when_is_none_for_non_evaluated_output_port

def test_ws_when_is_none_for_non_evaluated_output_port():
    pg = PortGraph()
    pg.add_vertex(0)
    pg.add_out_port(0, "out", 0)

    ws = WorkflowState(pg)
    assert ws.when(0) is None
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:7,代码来源:test_state.py

示例3: test_ws_when_raise_key_error_for_unset_param

def test_ws_when_raise_key_error_for_unset_param():
    pg = PortGraph()
    pg.add_vertex(0)
    pg.add_in_port(0, "in", 0)

    ws = WorkflowState(pg)
    assert_raises(KeyError, lambda: ws.when(0))
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:7,代码来源:test_state.py

示例4: test_evaluation_do_not_reevaluate_same_node

def test_evaluation_do_not_reevaluate_same_node():
    visited = []

    def func():
        visited.append("yes")

    pg = PortGraph()
    n = FuncNode(func)
    pg.add_actor(n, 0)
    pg.add_actor(n, 1)

    env = EvaluationEnvironment()
    algo = BruteEvaluation(pg)

    ws = WorkflowState(pg)
    algo.eval(env, ws, 0)
    assert len(visited) == 1

    algo.eval(env, ws, 1)
    assert len(visited) == 2

    algo.eval(env, ws, 0)
    assert len(visited) == 2

    env.new_execution()
    algo.eval(env, ws, 0)
    assert len(visited) == 3
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:27,代码来源:test_evaluation.py

示例5: test_ws_when_is_last_evaluation_for_output_port

def test_ws_when_is_last_evaluation_for_output_port():
    pg = PortGraph()
    pg.add_vertex(0)
    pg.add_out_port(0, "out", 0)

    ws = WorkflowState(pg)
    ws.set_last_evaluation(0, 1)
    assert ws.when(0) == 1
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:8,代码来源:test_state.py

示例6: test_ws_when_set_explicitly_for_params

def test_ws_when_set_explicitly_for_params():
    pg = PortGraph()
    pg.add_vertex(0)
    pg.add_in_port(0, "in", 0)

    ws = WorkflowState(pg)
    ws.store_param(0, "param", 10)
    assert ws.when(0) == 10
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:8,代码来源:test_state.py

示例7: test_ws_nodes_not_evaluated_on_creation

def test_ws_nodes_not_evaluated_on_creation():
    pg = PortGraph()
    pg.add_vertex(0)
    pg.add_vertex(1)

    ws = WorkflowState(pg)
    assert ws.last_evaluation(0) is None
    assert ws.last_evaluation(1) is None
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:8,代码来源:test_state.py

示例8: test_ws_nodes_last_evaluation

def test_ws_nodes_last_evaluation():
    pg = PortGraph()
    pg.add_vertex(0)
    pg.add_vertex(1)

    ws = WorkflowState(pg)
    ws.set_last_evaluation(0, 1)
    assert ws.last_evaluation(0) == 1
    assert ws.last_evaluation(1) is None
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:9,代码来源:test_state.py

示例9: test_ws_retrieve_stored_data_on_output_port

def test_ws_retrieve_stored_data_on_output_port():
    pg = PortGraph()
    pg.add_vertex(0)
    pg.add_out_port(0, "out", 0)
    ws = WorkflowState(pg)

    ws.store(0, "data")
    assert_raises(KeyError, lambda: ws.get(1))

    assert ws.get(0) == "data"
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:10,代码来源:test_state.py

示例10: test_evaluation_new_require_evaluation

def test_evaluation_new_require_evaluation():
    pg = PortGraph()
    pg.add_vertex(0)

    algo = BruteEvaluation(pg)
    assert id(algo.portgraph()) == id(pg)

    env = EvaluationEnvironment()
    ws = WorkflowState(pg)
    assert algo.requires_evaluation(env, ws)
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:10,代码来源:test_evaluation.py

示例11: test_evaluation_needs_ready_to_evaluate_state

def test_evaluation_needs_ready_to_evaluate_state():
    def func(a, b):
        c = a + b
        return c

    pg = PortGraph()
    n = FuncNode(func)
    pg.add_actor(n, 0)

    algo = BruteEvaluation(pg)

    ws = WorkflowState(pg)
    assert_raises(EvaluationError, lambda: algo.eval(None, ws))
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:13,代码来源:test_evaluation.py

示例12: test_evaluation_propagated_upstream

def test_evaluation_propagated_upstream():
    visited = []

    def func(txt):
        visited.append(txt)
        return txt

    pg = PortGraph()
    n = FuncNode(func)
    pg.add_actor(n, 0)
    pg.add_actor(n, 1)
    pg.connect(pg.out_port(0, 'txt'), pg.in_port(1, 'txt'))

    algo = BruteEvaluation(pg)

    ws = WorkflowState(pg)
    env = EvaluationEnvironment()
    ws.store_param(pg.in_port(0, 'txt'), "txt", 0)

    algo.eval(env, ws, 0)
    assert len(visited) == 1
    algo.eval(env, ws, 1)
    assert len(visited) == 2

    env.new_execution()
    algo.eval(env, ws, 1)
    assert len(visited) == 4
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:27,代码来源:test_evaluation.py

示例13: test_portgraph_out_port

def test_portgraph_out_port():
    pg = PortGraph()
    assert_raises(InvalidVertex, lambda: pg.out_port(0, None))

    vid = pg.add_vertex()
    assert_raises(InvalidPort, lambda: pg.out_port(vid, None))

    pg.add_in_port(vid, "toto")
    assert_raises(InvalidPort, lambda: pg.out_port(vid, None))

    for lpid in [0, 1, "a", None]:
        assert_raises(InvalidPort, lambda: pg.out_port(vid, "toto"))
        pid = pg.add_out_port(vid, lpid)
        assert pg.out_port(vid, lpid) == pid
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:14,代码来源:test_port_graph.py

示例14: test_portgraph_is_out_port

def test_portgraph_is_out_port():
    pg = PortGraph()
    vid = pg.add_vertex()

    assert_raises(InvalidPort, lambda: pg.is_out_port(None))
    assert_raises(InvalidPort, lambda: pg.is_out_port(0))

    pid = pg.add_out_port(vid, "out")
    assert_raises(InvalidPort, lambda: pg.is_out_port(pid + 1))
    assert pg.is_out_port(pid)

    pid = pg.add_in_port(vid, "in")
    assert not pg.is_out_port(pid)
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:13,代码来源:test_port_graph.py

示例15: test_evaluation_eval_all_nodes

def test_evaluation_eval_all_nodes():
    visited = []

    def func():
        visited.append("yes")

    pg = PortGraph()
    n = FuncNode(func)
    pg.add_actor(n, 0)
    pg.add_actor(n, 1)

    algo = BruteEvaluation(pg)

    env = EvaluationEnvironment()
    ws = WorkflowState(pg)
    algo.eval(env, ws)

    assert len(visited) == 2
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:18,代码来源:test_evaluation.py


注:本文中的openalea.workflow.port_graph.PortGraph类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。