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


Python PackageManager.init方法代码示例

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


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

示例1: test_auto_io

# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import init [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

示例2: test1

# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import init [as 别名]
def test1(directory):
    from openalea.core.pkgmanager import PackageManager
    pm = PackageManager()
    pm.init(verbose=False)
    obj = vlab_object(directory, pm)
    pkg = obj.get_package()
    pkg.write()
开发者ID:VirtualPlants,项目名称:openalea,代码行数:9,代码来源:vlab.py

示例3: test_instantiate_compositenode

# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import init [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_in_eval

# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import init [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

示例5: test_nodewriter

# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import init [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

示例6: test_to_factory

# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import init [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

示例7: test_save_workspace

# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import init [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

示例8: test_recursion_factory

# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import init [as 别名]
def test_recursion_factory():
    """ Test Recursion detection"""

    pm = PackageManager()
    pm.init()
    pkg = Package("compositenode", {})

    sgfactory1 = CompositeNodeFactory("graph1")
    sgfactory2 = CompositeNodeFactory("graph2")

    map(pkg.add_factory, (sgfactory1, sgfactory2))

    assert len(pkg.get_names()) == 2

    pm.add_package(pkg)

    n1 = sgfactory1.instantiate()
    n2 = sgfactory1.instantiate()
    # build the compositenode factory
    n1.add_node(n2)
    n2.add_node(n1)

    n1.to_factory(sgfactory1)
    n2.to_factory(sgfactory2)

    #sgfactory1.add_nodefactory ( ("compositenode", "graph2"))
    #sgfactory2.add_nodefactory ( ("compositenode", "graph1"))

    try:
        sg = sgfactory1.instantiate()
        assert False
    except RecursionError:
        assert True
开发者ID:MarieLatutu,项目名称:openalea-components,代码行数:35,代码来源:test_compositenode.py

示例9: _test_lambda

# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import init [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

示例10: test_data

# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import init [as 别名]
def test_data():
    """test data"""
    pm = PackageManager()
    pm.init()

    assert pm['pkg_test']['file1.txt']
    assert pm['pkg_test']['file2.txt']
开发者ID:VirtualPlants,项目名称:openalea,代码行数:9,代码来源:test_data.py

示例11: test_multi_out_eval

# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import init [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

示例12: test_compositenodewriter

# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import init [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

示例13: test_category

# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import init [as 别名]
def test_category():
    pkgman = PackageManager()

    pkgman.init()
    pkgman.find_and_register_packages()

    # test if factory are dedoubled
    for cat in pkgman.category.values():
        s = set()
        for factory in cat:
            assert not factory in s
            s.add(factory)
开发者ID:gbaty,项目名称:openalea,代码行数:14,代码来源:test_packagemanager.py

示例14: load_package_manager

# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import init [as 别名]
def load_package_manager(*args):
    """ Return the package manager

    :param pkg_id:  package id
    :param node_id: node id
    :returns: package manager

    """
    pm = PackageManager()
    pm.init(verbose=False)

    return pm
开发者ID:VirtualPlants,项目名称:openalea,代码行数:14,代码来源:alea.py

示例15: test_case_1

# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import init [as 别名]
    def test_case_1(self):

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

        path = os.path.join(os.path.curdir, "tstpkg")
        mypackage = UserPackage("DummyPkg", metainfo, path)


        factory = mypackage.create_user_node("TestFact",
                                             "category test",
                                             "this is a test",
                                             gen_port_list(3),
                                             gen_port_list(2))
        assert path in factory.search_path
        assert len(factory.inputs)==3
        assert len(factory.outputs)==2

        assert os.path.exists("tstpkg/TestFact.py")
        execfile("tstpkg/TestFact.py")

        mypackage.write()
        assert os.path.exists("tstpkg/__wralea__.py")
        assert os.path.exists("tstpkg/__init__.py")
        execfile("tstpkg/__wralea__.py")

        # Test_clone_package
        path = os.path.join(os.path.curdir, "clonepkg")
        pkg2 = UserPackage("ClonePkg", metainfo, path)
        print pkg2.wralea_path


        # todo this is not working !!
        from openalea.core.pkgmanager import PackageManager
        pm = PackageManager()
        pm.add_wralea_path(path, pm.temporary_wralea_paths)
        pm.init()
        pkg2.clone_from_package(mypackage)
        pkg2.write()

        assert len(pkg2) == 1
        assert len(pkg2["TestFact"].inputs) == 3
        assert id(pkg2["TestFact"]) != id(mypackage["TestFact"])
        assert os.path.exists(path)
        assert os.path.exists(os.path.join(path, '__wralea__.py'))
        assert os.path.exists(os.path.join(path, '__init__.py'))
        assert os.path.exists(os.path.join(path, 'TestFact.py'))
开发者ID:VirtualPlants,项目名称:openalea,代码行数:54,代码来源:test_package.py


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