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


Python PortGraph.add_out_port方法代码示例

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


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

示例1: 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_out_port [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

示例2: test_ws_retrieve_data_on_input_ports

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_out_port [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

示例3: test_portgraph_add_actor

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_out_port [as 别名]
def test_portgraph_add_actor():
    pg = PortGraph()
    vid1 = pg.add_vertex()
    actor = Node()
    keys = {"toto", 1, "titi"}
    for key in keys:
        actor.add_input(key, "descr")
        actor.add_output(key, "descr")

    # bad actor
    assert_raises(AttributeError, lambda: pg.add_actor(None))
    assert len(pg) == 1
    assert_raises(AttributeError, lambda: pg.add_actor(None, vid1 + 1))
    assert len(pg) == 1
    # vertex id already used
    assert_raises(InvalidVertex, lambda: pg.add_actor(actor, vid1))
    assert len(pg) == 1

    for key in actor.inputs():
        pg.add_in_port(vid1, key)

    for key in actor.outputs():
        pg.add_out_port(vid1, key)

    pg.set_actor(vid1, actor)
    # vertex id already used
    assert_raises(InvalidVertex, lambda: pg.add_actor(actor, vid1))
    assert len(pg) == 1

    vid2 = pg.add_actor(actor)
    assert pg.actor(vid2) == actor
    assert set(actor.inputs()) == keys
    assert set(pg.local_id(pid) for pid in pg.in_ports(vid2)) == keys
    assert set(actor.outputs()) == keys
    assert set(pg.local_id(pid) for pid in pg.out_ports(vid2)) == keys
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:37,代码来源:test_port_graph.py

示例4: test_portgraph_set_actor

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_out_port [as 别名]
def test_portgraph_set_actor():
    pg = PortGraph()
    assert_raises(InvalidVertex, lambda: pg.set_actor(0, None))

    actor = Node()
    for key in ("toto", 1, "titi"):
        actor.add_input(key, "descr")
        actor.add_output(key, "descr")

    assert_raises(InvalidVertex, lambda: pg.set_actor(0, actor))

    vid = pg.add_vertex()
    pg.set_actor(vid, None)
    assert pg.actor(vid) is None
    assert_raises(InvalidPort, lambda: pg.set_actor(vid, actor))

    for key in actor.inputs():
        pg.add_in_port(vid, key)

    assert_raises(InvalidPort, lambda: pg.set_actor(vid, actor))

    for key in actor.outputs():
        pg.add_out_port(vid, key)

    pg.set_actor(vid, actor)
    assert pg.actor(vid) == actor

    pg.set_actor(vid, None)
    assert pg.actor(vid) is None
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:31,代码来源:test_port_graph.py

示例5: 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_out_port [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

示例6: test_ws_when_is_none_on_creation

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_out_port [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

示例7: test_ws_retrieve_stored_data_on_output_port

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_out_port [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

示例8: test_ws_is_created_empty

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_out_port [as 别名]
def test_ws_is_created_empty():
    pg = PortGraph()
    ws = WorkflowState(pg)
    assert len(tuple(ws.items())) == 0
    assert id(ws.portgraph()) == id(pg)

    pg.add_vertex(0)
    pg.add_in_port(0, "in", 0)
    pg.add_out_port(0, "out", 1)

    ws = WorkflowState(pg)
    assert len(tuple(ws.items())) == 0
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:14,代码来源:test_state.py

示例9: test_ws_store_param_only_on_lonely_input_ports

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

    ws = WorkflowState(pg)

    assert_raises(UserWarning, lambda: ws.store_param(1, "param", 0))
    assert_raises(UserWarning, lambda: ws.store_param(2, "param", 0))
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:15,代码来源:test_state.py

示例10: test_portgraph_in_port

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_out_port [as 别名]
def test_portgraph_in_port():
    pg = PortGraph()
    assert_raises(InvalidVertex, lambda: pg.in_port(0, None))

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

    pg.add_out_port(vid, "toto")
    assert_raises(InvalidPort, lambda: pg.in_port(vid, None))

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

示例11: test_ws_sub_ready_for_evaluation_if_no_input_port

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

    ws = WorkflowState(pg)
    assert ws.is_ready_for_evaluation()

    subpg = get_upstream_subportgraph(pg, 1)
    subws = WorkflowState(subpg)
    assert subws.is_ready_for_evaluation()
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:16,代码来源:test_state.py

示例12: test_portgraph_add_out_port

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_out_port [as 别名]
def test_portgraph_add_out_port():
    pg = PortGraph()
    assert_raises(InvalidVertex, lambda: pg.add_out_port(0, "toto"))

    vid = pg.add_vertex()
    pid = pg.add_out_port(vid, "port")

    # raise error if reuse same global port id
    assert_raises(IndexError, lambda: pg.add_out_port(vid, "toto", pid))
    # raise error if reuse same local port id
    assert_raises(InvalidPort, lambda: pg.add_out_port(vid, "port"))

    assert tuple(pg.out_ports(vid)) == (pid,)
    assert pg.local_id(pid) == "port"
    assert pg.out_port(vid, "port") == pid
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:17,代码来源:test_port_graph.py

示例13: test_portgraph_connect

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

    # invalid ports
    assert_raises(InvalidPort, lambda: pg.connect(0, 1))
    # invalid source port
    pid1 = pg.add_in_port(vid1, "in")
    assert_raises(InvalidPort, lambda: pg.connect(pid1 + 1, pid1))
    # invalid out port
    pid2 = pg.add_out_port(vid2, "out")
    assert_raises(InvalidPort, lambda: pg.connect(pid2, pid1 + pid2 + 1))
    # edge connection from in to out raise error
    assert_raises(InvalidPort, lambda: pg.connect(pid1, pid2))

    eid = pg.connect(pid2, pid1)
    assert pg.source_port(eid) == pid2
    assert pg.target_port(eid) == pid1
    assert tuple(pg.connected_edges(pid1)) == (eid,)
    assert tuple(pg.connected_edges(pid2)) == (eid,)
    assert pid1 in pg.connected_ports(pid2)
    assert pid2 in pg.connected_ports(pid1)

    # can not duplicate edge
    assert_raises(InvalidEdge, lambda: pg.connect(pid2, pid1, eid))
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:28,代码来源:test_port_graph.py

示例14: test_portgraph_set_actor_port_order_not_important

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

    actor = Node()
    keys = ("toto", 1, "titi")
    for key in keys:
        actor.add_input(key, "descr")
        actor.add_output(key, "descr")

    vid = pg.add_vertex()
    for k in reversed(keys):
        pg.add_in_port(vid, k)
        pg.add_out_port(vid, k)

    pg.set_actor(vid, actor)
    assert pg.actor(vid) == actor
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:18,代码来源:test_port_graph.py

示例15: portgraph_nb_connections

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_out_port [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


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