當前位置: 首頁>>代碼示例>>Python>>正文


Python PortGraph.remove_port方法代碼示例

本文整理匯總了Python中openalea.workflow.port_graph.PortGraph.remove_port方法的典型用法代碼示例。如果您正苦於以下問題:Python PortGraph.remove_port方法的具體用法?Python PortGraph.remove_port怎麽用?Python PortGraph.remove_port使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在openalea.workflow.port_graph.PortGraph的用法示例。


在下文中一共展示了PortGraph.remove_port方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_portgraph_remove_port

# 需要導入模塊: from openalea.workflow.port_graph import PortGraph [as 別名]
# 或者: from openalea.workflow.port_graph.PortGraph import remove_port [as 別名]
def test_portgraph_remove_port():
    pg = PortGraph()
    vid1 = pg.add_vertex()
    vid2 = pg.add_vertex()

    pid1 = pg.add_in_port(vid1, "in")
    pid2 = pg.add_out_port(vid2, "out")

    pg.connect(pid2, pid1)

    # raise error if global port id dos not exist
    assert_raises(InvalidPort, lambda: pg.remove_port(pid1 + pid2 + 1))

    pg.remove_port(pid1)
    assert len(tuple(pg.ports(vid1))) == 0
    assert tuple(pg.ports(vid2)) == (pid2,)
    assert pg.nb_connections(pid2) == 0
開發者ID:revesansparole,項目名稱:oaworkflow,代碼行數:19,代碼來源:test_port_graph.py

示例2: test_portgraph_big

# 需要導入模塊: from openalea.workflow.port_graph import PortGraph [as 別名]
# 或者: from openalea.workflow.port_graph.PortGraph import remove_port [as 別名]
def test_portgraph_big():
    pg = PortGraph()
    vid1 = pg.add_vertex()
    pid11 = pg.add_out_port(vid1, "out")
    vid2 = pg.add_vertex()
    pid21 = pg.add_out_port(vid2, "out")

    vid3 = pg.add_vertex()
    pid31 = pg.add_in_port(vid3, "in1")
    pid32 = pg.add_in_port(vid3, "in2")
    pid33 = pg.add_out_port(vid3, "res")

    vid4 = pg.add_vertex()
    pid41 = pg.add_in_port(vid4, "in")

    eid1 = pg.connect(pid11, pid31)
    eid2 = pg.connect(pid21, pid32)
    pg.connect(pid33, pid41)

    assert pg.source_port(eid1) == pid11
    assert pg.target_port(eid2) == pid32
    assert set(pg.out_ports(vid1)) == {pid11}
    assert set(pg.in_ports(vid3)) == {pid31, pid32}
    assert set(pg.ports(vid3)) == {pid31, pid32, pid33}
    assert pg.is_in_port(pid31)
    assert pg.is_out_port(pid11)
    assert pg.vertex(pid11) == vid1
    assert set(pg.connected_ports(pid11)) == {pid31}
    assert set(pg.connected_edges(pid21)) == {eid2}
    assert pg.out_port(vid1, "out") == pid11
    assert pg.in_port(vid3, "in1") == pid31

    assert_raises(InvalidPort, lambda: pg.connect(pid11, pid33))

    pg.remove_port(pid33)
    assert set(pg.connected_ports(pid41)) == set()
    assert set(pg.out_edges(vid3)) == set()
    assert_raises(InvalidPort, lambda: pg.is_in_port(pid33))
開發者ID:revesansparole,項目名稱:oaworkflow,代碼行數:40,代碼來源:test_port_graph.py

示例3: test_ws_dos_not_allow_graph_editing

# 需要導入模塊: from openalea.workflow.port_graph import PortGraph [as 別名]
# 或者: from openalea.workflow.port_graph.PortGraph import remove_port [as 別名]
def test_ws_dos_not_allow_graph_editing():
    pg = PortGraph()
    ws = WorkflowState(pg)

    assert ws.portgraph_still_valid()
    pg.add_vertex(0)
    assert not ws.portgraph_still_valid()

    ws = WorkflowState(pg)
    assert ws.portgraph_still_valid()
    pg.add_out_port(0, "out", 0)
    assert not ws.portgraph_still_valid()

    pg.add_vertex(1)
    pg.add_in_port(1, "in", 1)
    ws = WorkflowState(pg)
    assert ws.portgraph_still_valid()
    pg.connect(0, 1)
    assert not ws.portgraph_still_valid()

    ws = WorkflowState(pg)
    assert ws.portgraph_still_valid()
    pg.remove_port(0)
    assert not ws.portgraph_still_valid()
開發者ID:revesansparole,項目名稱:oaworkflow,代碼行數:26,代碼來源:test_state.py


注:本文中的openalea.workflow.port_graph.PortGraph.remove_port方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。