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


Python PackageManager.get_node方法代碼示例

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


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

示例1: test_multi_in_eval

# 需要導入模塊: from openalea.core.pkgmanager import PackageManager [as 別名]
# 或者: from openalea.core.pkgmanager.PackageManager import get_node [as 別名]
def test_multi_in_eval():
    """ Test multiple out connection"""
    pm = PackageManager()
    pm.init()

    sg = CompositeNode()

    # build the compositenode factory
    val1id = sg.add_node(pm.get_node("Catalog.Data", "string"))
    val2id = sg.add_node(pm.get_node("Catalog.Data", "string"))
    val3id = sg.add_node(pm.get_node("Catalog.Data", "string"))

    sg.connect(val1id, 0, val3id, 0)
    sg.connect(val2id, 0, val3id, 0)


    sgfactory = CompositeNodeFactory("testlazyeval")
    sg.to_factory(sgfactory)
    # allocate the compositenode
    sg = sgfactory.instantiate()

    sg.node(val1id).set_input(0, "teststring1")
    sg.node(val2id).set_input(0, "teststring2")
    sg()
    assert (sg.node(val3id).get_output(0) == "['teststring1', 'teststring2']")\
        or \
        (sg.node(val3id).get_output(0) == "['teststring2', 'teststring1']")
開發者ID:MarieLatutu,項目名稱:openalea-components,代碼行數:29,代碼來源:test_compositenode.py

示例2: test_auto_io

# 需要導入模塊: from openalea.core.pkgmanager import PackageManager [as 別名]
# 或者: from openalea.core.pkgmanager.PackageManager import get_node [as 別名]
def test_auto_io():
    """ Test auto io"""
    pm = PackageManager()
    pm.init()

    sg = CompositeNode()

    # build the compositenode factory
    val1id = sg.add_node(pm.get_node("Catalog.Data", "string"))
    val2id = sg.add_node(pm.get_node("Catalog.Data", "string"))
    val3id = sg.add_node(pm.get_node("Catalog.Data", "string"))

    sg.connect(val1id, 0, val3id, 0)
    sg.connect(val2id, 0, val3id, 0)

    sgfactory = CompositeNodeFactory("testlautoio")
    sg.to_factory(sgfactory, listid=[val1id, val2id, val3id], auto_io=True)

    # allocate the compositenode
    sg = sgfactory.instantiate()
    assert sg.get_nb_input() == 2
    assert sg.get_nb_output() == 1
    sg.set_input(0, "to")
    sg.set_input(1, "to")

    sg()
    res = sg.get_output(0)
    assert ''.join(eval(res)) == "toto"
開發者ID:MarieLatutu,項目名稱:openalea-components,代碼行數:30,代碼來源:test_compositenode.py

示例3: test_instantiate_compositenode

# 需要導入模塊: from openalea.core.pkgmanager import PackageManager [as 別名]
# 或者: from openalea.core.pkgmanager.PackageManager import get_node [as 別名]
def test_instantiate_compositenode():
    """test instantiation"""
    pm = PackageManager()
    pm.init()

    sg = CompositeNode()

    # build the compositenode factory
    addid = sg.add_node(pm.get_node("Catalog.Math", "+"))
    val1id = sg.add_node(pm.get_node("Catalog.Data", "float"))
    val2id = sg.add_node(pm.get_node("Catalog.Data", "float"))
    val3id = sg.add_node(pm.get_node("Catalog.Data", "float"))

    sg.connect(val1id, 0, addid, 0)
    sg.connect(val2id, 0, addid, 1)
    sg.connect(addid, 0, val3id, 0)

    sgfactory = CompositeNodeFactory("addition")
    sg.to_factory(sgfactory)

    # allocate the compositenode
    sg = sgfactory.instantiate()
    sg.node(val1id).set_input(0, 2.)
    sg.node(val2id).set_input(0, 3.)

    # evaluation
    sg()

    assert sg.node(val3id).get_output(0) == 5.
開發者ID:MarieLatutu,項目名稱:openalea-components,代碼行數:31,代碼來源:test_compositenode.py

示例4: test_multi_out_eval

# 需要導入模塊: from openalea.core.pkgmanager import PackageManager [as 別名]
# 或者: from openalea.core.pkgmanager.PackageManager import get_node [as 別名]
def test_multi_out_eval():
    """ Test multiple out connection"""

    pm = PackageManager()
    pm.init()

    sg = CompositeNode()

    # build the compositenode factory
    val1id = sg.add_node(pm.get_node("Catalog.Data", "string"))
    val2id = sg.add_node(pm.get_node("Catalog.Data", "string"))
    val3id = sg.add_node(pm.get_node("Catalog.Data", "string"))

    sg.connect(val1id, 0, val2id, 0)
    sg.connect(val1id, 0, val3id, 0)

    sgfactory = CompositeNodeFactory("testlazyeval")
    sg.to_factory(sgfactory)
    # allocate the compositenode
    sg = sgfactory.instantiate()

    sg.node(val1id).set_input(0, "teststring")
    sg()
    assert sg.node(val2id).get_output(0) == "teststring"
    assert sg.node(val3id).get_output(0) == "teststring"

    #partial evaluation
    sg.node(val1id).set_input(0, "teststring2")
    sg.eval_as_expression(val2id)
    assert sg.node(val2id).get_output(0) == "teststring2"

    sg.eval_as_expression(val3id)
    assert sg.node(val3id).get_output(0) == "teststring2"
開發者ID:MarieLatutu,項目名稱:openalea-components,代碼行數:35,代碼來源:test_compositenode.py

示例5: test_compositenodewriter

# 需要導入模塊: from openalea.core.pkgmanager import PackageManager [as 別名]
# 或者: from openalea.core.pkgmanager.PackageManager import get_node [as 別名]
def test_compositenodewriter():

    setup_module()

    pm = PackageManager()
    pm.init()

    sg = CompositeNode(inputs=[dict(name="%d" % i) for i in xrange(3)],
                       outputs=[dict(name="%d" % i) for i in xrange(4)],
                      )

    # build the compositenode factory
    addid = sg.add_node(pm.get_node("pkg_test", "+"))
    val1id = sg.add_node(pm.get_node("pkg_test", "float"))
    val2id = sg.add_node(pm.get_node("pkg_test", "float"))
    val3id = sg.add_node(pm.get_node("pkg_test", "float"))

    sg.connect(val1id, 0, addid, 0)
    sg.connect(val2id, 0, addid, 1)
    sg.connect(addid, 0, val3id, 0)
    sg.connect(val3id, 0, sg.id_out, 0)
    sgfactory = CompositeNodeFactory("addition")
    sg.to_factory(sgfactory)
    # Package
    metainfo = {'version': '0.0.1',
               'license': 'CECILL-C',
               'authors': 'OpenAlea Consortium',
               'institutes': 'INRIA/CIRAD',
               'description': 'Base library.',
               'url': 'http://openalea.gforge.inria.fr'}

    package1 = pm.create_user_package("MyTestPackage", 
                                      metainfo, os.path.curdir)
    package1.add_factory(sgfactory)
    print package1.keys()
    assert 'addition' in package1
    package1.write()

    sg = sgfactory.instantiate()

    sg.node(val1id).set_input(0, 2.)
    sg.node(val2id).set_input(0, 3.)

    # evaluation
    sg()
    print sg.node(val3id).get_output(0)
    assert sg.node(val3id).get_output(0) == 5.

    print "nb vertices", len(sg)
    assert len(sg) == 6

    pm.init()
    newsg = pm.get_node('MyTestPackage', 'addition')
    print "nb vertices", len(newsg)
    assert len(newsg) == 6
開發者ID:VirtualPlants,項目名稱:openalea,代碼行數:57,代碼來源:test_persistence.py

示例6: test_compositenodeio

# 需要導入模塊: from openalea.core.pkgmanager import PackageManager [as 別名]
# 或者: from openalea.core.pkgmanager.PackageManager import get_node [as 別名]
def test_compositenodeio():
    """ Test IO"""
    pm = PackageManager()
    pm.init()

    pkg = Package("compositenode", {})

    # create a compositenode with 2 in and 1 out
    # the compositenode does an addition
    sg = CompositeNode(inputs=(dict(name="in1", interface=None, value=None),\
                              dict(name="in2", interface=None, value=None)),
                      outputs=(dict(name="out", interface=None), ), )
    addid = sg.add_node(pm.get_node("Catalog.Math", "+"))

    sg.connect(sg.id_in, 0, addid, 0)
    sg.connect(sg.id_in, 1, addid, 1)
    sg.connect(addid, 0, sg.id_out, 0)

    sgfactory = CompositeNodeFactory("additionsg")
    sg.to_factory(sgfactory)

    sg1= sgfactory.instantiate()
    sg1.set_input(0, 2.)
    sg1.set_input(1, 3.)
    sg1()

    assert sg1.get_output(0)==5.

    pkg.add_factory(sgfactory)
    pm.add_package(pkg)

    sg = CompositeNode()
    addid = sg.add_node(pm.get_node("compositenode", "additionsg"))
    val1id = sg.add_node(pm.get_node("Catalog.Data", "float"))
    val2id = sg.add_node(pm.get_node("Catalog.Data", "float"))
    val3id = sg.add_node(pm.get_node("Catalog.Data", "float"))

    sg.connect(val1id, 0, addid, 0)
    sg.connect(val2id, 0, addid, 1)
    sg.connect(addid, 0, val3id, 0)

    sgfactory2 = CompositeNodeFactory("testio")
    sg.to_factory(sgfactory2)
    # allocate the compositenode

    sg = sgfactory2.instantiate()
    sg.node(val1id).set_input(0, 2.)
    sg.node(val2id).set_input(0, 3.)

    # evaluation
    sg()
    assert sg.node(val3id).get_output(0)==5.
開發者ID:MarieLatutu,項目名稱:openalea-components,代碼行數:54,代碼來源:test_compositenode.py

示例7: test_nodewriter

# 需要導入模塊: from openalea.core.pkgmanager import PackageManager [as 別名]
# 或者: from openalea.core.pkgmanager.PackageManager import get_node [as 別名]
def test_nodewriter():
    """test node writer"""
    setup_module()

    pm = PackageManager()
    pm.clear()
    pm.init()

    # Package
    metainfo = {'version': '0.0.1',
               'license': 'CECILL-C',
               'authors': 'OpenAlea Consortium',
               'institutes': 'INRIA/CIRAD',
               'description': 'Base library.',
               'url': 'http://openalea.gforge.inria.fr'}

    package1 = pm.create_user_package("MyTestPackage", \
        metainfo, os.path.curdir)
    assert package1 != None

    nf = package1.create_user_node(name="mynode",
                                      category='test',
                                      description="descr",
                                      inputs=(),
                                      outputs=(),
                                      )
    package1.write()
    pm.init()
    newsg = pm.get_node('MyTestPackage', 'mynode')
    package1.remove_files()
開發者ID:VirtualPlants,項目名稱:openalea,代碼行數:32,代碼來源:test_persistence.py

示例8: test_to_factory

# 需要導入模塊: from openalea.core.pkgmanager import PackageManager [as 別名]
# 或者: from openalea.core.pkgmanager.PackageManager import get_node [as 別名]
def test_to_factory():
    """ Create a compositenode, generate its factory and reintantiate it """

    pm = PackageManager()
    pm.init()

    sg = CompositeNode()

    n1 = pm.get_node("Catalog.Data", "float")
    n2 = pm.get_node("Catalog.Data", "float")
    e1 = sg.add_node(n1)
    e2 = sg.add_node(n2)
    sg.connect(e1, 0, e2, 0)

    n1.set_input(0, 34.)
    sg()
    assert n2.get_output(0)==34.

    sgfactory = CompositeNodeFactory("factorytest")
    sg.to_factory(sgfactory)

    sg2 = sgfactory.instantiate()

    assert len(list(sg2.vertices()))==2+2 # two nodes + in/ou
    assert len(list(sg2.edges()))==1

    sg2.node(e1).set_input(0, 3.)
    sg2()
    assert sg2.node(e2).get_output(0)==3.

    return pm, sg, sgfactory
開發者ID:MarieLatutu,項目名稱:openalea-components,代碼行數:33,代碼來源:test_compositenode.py

示例9: test_save_workspace

# 需要導入模塊: from openalea.core.pkgmanager import PackageManager [as 別名]
# 或者: from openalea.core.pkgmanager.PackageManager import get_node [as 別名]
def test_save_workspace():
    pm = PackageManager()
    pm.init()

    asession = Session()

    import sys

    sgfactory = CompositeNodeFactory(name="SubGraphExample",
                                description= "Examples",
                                category = "Examples",
                               )
    sg= CompositeNode()
    # build the subgraph factory

    addid = sg.add_node(pm.get_node("pkg_test", "float"))
    sg.to_factory(sgfactory)
    instance = sgfactory.instantiate()

    instance.actor(addid).set_input(0, 3)
    asession.add_workspace(instance)

    asession.save('test.pic')

    asession.workspaces = []
    asession.load('test.pic')
    try:
        os.remove('test.pic')
    except:
        os.remove('test.pic.db')

    i = asession.workspaces[0]
    assert type(i) == type(instance)
開發者ID:VirtualPlants,項目名稱:openalea,代碼行數:35,代碼來源:test_session.py

示例10: _test_lambda

# 需要導入模塊: from openalea.core.pkgmanager import PackageManager [as 別名]
# 或者: from openalea.core.pkgmanager.PackageManager import get_node [as 別名]
def _test_lambda():
    """ Test for lambda functions"""
    pm = PackageManager()
    pm.init()

    import testnodes
    testnodes.register_packages(pm)

    for t, id, res in (
        ('LambdaFactoriel', 2, 362880),
        ('testlambdaFor', 3, 12),
        ('testlambdaFor', 9, [12, 5]),
        ('testorder', 4, [1., 2.]),
        ('TestLambda', 3, map(lambda x: (x+5)*5, range(10))),
        ('testlambda2', 10, filter(lambda x: x>=2 and x <= 7, range(10))),
        ('testlambda3', 3, map(lambda y: filter(lambda x: x>=7, y), \
            [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], \
            [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], \
            [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]])),
        ('test_str', 5, ['toto', 'toto']),
        ):

        n = pm.get_node("TestLambda", t)
        n()

        print n.node(id).get_output(0), res
        assert n.node(id).get_output(0) == res
開發者ID:VirtualPlants,項目名稱:openalea,代碼行數:29,代碼來源:test_lambda.py

示例11: test_compositenode_creation_without_edges

# 需要導入模塊: from openalea.core.pkgmanager import PackageManager [as 別名]
# 或者: from openalea.core.pkgmanager.PackageManager import get_node [as 別名]
def test_compositenode_creation_without_edges():
    """test compositenode creation without edges"""
    pm = PackageManager()
    pm.init()

    sg = CompositeNode()

    # build the compositenode factory
    addid = sg.add_node(pm.get_node("Catalog.Math", "+"))
    val1id = sg.add_node(pm.get_node("Catalog.Data", "float"))
    val2id = sg.add_node(pm.get_node("Catalog.Data", "float"))
    val3id = sg.add_node(pm.get_node("Catalog.Data", "float"))

    sgfactory = CompositeNodeFactory("addition")
    sg.to_factory(sgfactory)
    # allocate the compositenode
    sg = sgfactory.instantiate()

    assert len(sg) == 4+2
開發者ID:MarieLatutu,項目名稱:openalea-components,代碼行數:21,代碼來源:test_compositenode.py

示例12: test_tutorial

# 需要導入模塊: from openalea.core.pkgmanager import PackageManager [as 別名]
# 或者: from openalea.core.pkgmanager.PackageManager import get_node [as 別名]
def test_tutorial():
    #app = QtGui.QApplication(sys.argv)
    
    path = os.path.join( os.path.abspath(os.path.dirname(__file__)), "tutorial_standbuilder")
    image = os.path.join(path, "stand.csv.png")
    try:
        os.remove(image)
    except:
        pass


    pm = PackageManager()
    pm.init()

    pm.load_directory(path)
    n = pm.get_node("tutorial_standbuilder", "gen_images")

    print path
    n.actor(4).set_input(0, path)
開發者ID:kkremitzki,項目名稱:plantgl,代碼行數:21,代碼來源:test_tutorial.py


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