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


Python PortGraph.add_vertex方法代码示例

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


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

示例1: test_portgraph_connected_ports

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_vertex [as 别名]
def test_portgraph_connected_ports():
    pg = PortGraph()
    vid1 = pg.add_vertex()
    vid2 = pg.add_vertex()
    vid3 = pg.add_vertex()

    assert_raises(InvalidPort, lambda: tuple(pg.connected_ports(0)))

    pid1 = pg.add_in_port(vid1, 0)
    pid2 = pg.add_in_port(vid1, 1)
    pid3 = pg.add_out_port(vid2, 0)
    pid4 = pg.add_out_port(vid3, 0)

    for pid in (pid1, pid2, pid3, pid4):
        assert len(tuple(pg.connected_ports(pid))) == 0

    pg.connect(pid3, pid1)
    assert tuple(pg.connected_ports(pid3)) == (pid1,)
    assert tuple(pg.connected_ports(pid1)) == (pid3,)
    for pid in (pid2, pid4):
        assert len(tuple(pg.connected_ports(pid))) == 0

    pg.connect(pid4, pid1)
    assert tuple(pg.connected_ports(pid3)) == (pid1,)
    assert tuple(pg.connected_ports(pid4)) == (pid1,)
    assert sorted(pg.connected_ports(pid1)) == sorted((pid3, pid4))
    assert len(tuple(pg.connected_ports(pid2))) == 0

    pg.connect(pid4, pid2)
    assert tuple(pg.connected_ports(pid3)) == (pid1,)
    assert sorted(pg.connected_ports(pid4)) == sorted((pid1, pid2))
    assert sorted(pg.connected_ports(pid1)) == sorted((pid3, pid4))
    assert tuple(pg.connected_ports(pid2)) == (pid4,)
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:35,代码来源:test_port_graph.py

示例2: test_ws_when_is_none_for_non_evaluated_output_port

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_vertex [as 别名]
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,代码行数:9,代码来源:test_state.py

示例3: test_ws_when_raise_key_error_for_unset_param

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_vertex [as 别名]
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,代码行数:9,代码来源:test_state.py

示例4: portgraph_nb_connections

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_vertex [as 别名]
def portgraph_nb_connections():
    pg = PortGraph()
    vid1 = pg.add_vertex()
    vid2 = pg.add_vertex()
    vid3 = pg.add_vertex()

    assert_raises(InvalidPort, lambda: pg.nb_connections(0))

    pid1 = pg.add_in_port(vid1, 0)
    pid2 = pg.add_in_port(vid1, 1)
    pid3 = pg.add_out_port(vid2, 0)
    pid4 = pg.add_out_port(vid3, 0)

    for pid in (pid1, pid2, pid3, pid4):
        assert pg.nb_connections(pid) == 0

    pg.connect(pid3, pid1)
    assert pg.nb_connections(pid3) == 1
    assert pg.nb_connections(pid1) == 1
    assert pg.nb_connections(pid2) == 0
    assert pg.nb_connections(pid4) == 0

    pg.connect(pid4, pid1)
    assert pg.nb_connections(pid3) == 1
    assert pg.nb_connections(pid4) == 1
    assert pg.nb_connections(pid1) == 2
    assert pg.nb_connections(pid2) == 0

    pg.connect(pid4, pid2)
    assert pg.nb_connections(pid3) == 1
    assert pg.nb_connections(pid4) == 2
    assert pg.nb_connections(pid1) == 2
    assert pg.nb_connections(pid2) == 1
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:35,代码来源:test_port_graph.py

示例5: test_portgraph_connected_edges

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_vertex [as 别名]
def test_portgraph_connected_edges():
    pg = PortGraph()
    vid1 = pg.add_vertex()
    vid2 = pg.add_vertex()
    vid3 = pg.add_vertex()

    assert_raises(InvalidPort, lambda: tuple(pg.connected_edges(0)))

    pid1 = pg.add_in_port(vid1, 0)
    pid2 = pg.add_in_port(vid1, 1)
    pid3 = pg.add_out_port(vid2, 0)
    pid4 = pg.add_out_port(vid3, 0)

    # test vertices and ports are created without connections
    for pid in (pid1, pid2, pid3, pid4):
        assert len(tuple(pg.connected_edges(pid))) == 0

    eid1 = pg.connect(pid3, pid1)
    assert tuple(pg.connected_edges(pid3)) == (eid1,)
    assert tuple(pg.connected_edges(pid1)) == (eid1,)
    for pid in (pid2, pid4):
        assert len(tuple(pg.connected_edges(pid))) == 0

    eid2 = pg.connect(pid4, pid1)
    assert tuple(pg.connected_edges(pid3)) == (eid1,)
    assert tuple(pg.connected_edges(pid4)) == (eid2,)
    assert sorted(pg.connected_edges(pid1)) == sorted((eid1, eid2))
    assert len(tuple(pg.connected_edges(pid2))) == 0

    eid3 = pg.connect(pid4, pid2)
    assert tuple(pg.connected_edges(pid3)) == (eid1,)
    assert sorted(pg.connected_edges(pid4)) == sorted((eid2, eid3))
    assert sorted(pg.connected_edges(pid1)) == sorted((eid1, eid2))
    assert tuple(pg.connected_edges(pid2)) == (eid3,)
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:36,代码来源:test_port_graph.py

示例6: test_ws_can_not_store_data_on_input_port

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_vertex [as 别名]
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,代码行数:9,代码来源:test_state.py

示例7: test_ws_retrieve_data_on_input_ports

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_vertex [as 别名]
def test_ws_retrieve_data_on_input_ports():
    pg = PortGraph()
    pg.add_vertex(0)
    pg.add_out_port(0, "out", 0)
    pg.add_vertex(1)
    pg.add_in_port(1, "in", 1)

    # non existing port
    ws = WorkflowState(pg)
    assert_raises(KeyError, lambda: ws.get(10))

    # lonely input port without data
    ws = WorkflowState(pg)
    assert_raises(KeyError, lambda: ws.get(1))

    # lonely input port with data
    ws.store_param(1, "param", 0)
    assert ws.get(1) == "param"

    # connected input port
    pg.connect(0, 1)
    ws = WorkflowState(pg)

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

示例8: test_ws_when_is_none_on_creation

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_vertex [as 别名]
def test_ws_when_is_none_on_creation():
    pg = PortGraph()
    pg.add_vertex(0)
    pg.add_in_port(0, "in", 0)
    pg.add_out_port(0, "out", 1)

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

示例9: test_ws_when_is_last_evaluation_for_output_port

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_vertex [as 别名]
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,代码行数:10,代码来源:test_state.py

示例10: test_ws_when_set_explicitly_for_params

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_vertex [as 别名]
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,代码行数:10,代码来源:test_state.py

示例11: test_ws_nodes_not_evaluated_on_creation

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_vertex [as 别名]
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,代码行数:10,代码来源:test_state.py

示例12: test_portgraph_add_vertex

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_vertex [as 别名]
def test_portgraph_add_vertex():
    pg = PortGraph()

    vid = pg.add_vertex()
    assert pg.nb_vertices() == 1
    assert_raises(InvalidVertex, lambda: pg.add_vertex(vid))

    assert len(tuple(pg.ports(vid))) == 0
    assert pg.actor(vid) is None
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:11,代码来源:test_port_graph.py

示例13: test_ws_nodes_last_evaluation

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_vertex [as 别名]
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,代码行数:11,代码来源:test_state.py

示例14: test_evaluation_new_require_evaluation

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_vertex [as 别名]
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,代码行数:12,代码来源:test_evaluation.py

示例15: test_ws_retrieve_stored_data_on_output_port

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_vertex [as 别名]
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,代码行数:12,代码来源:test_state.py


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