本文整理汇总了Python中openalea.core.pkgmanager.PackageManager.add_package方法的典型用法代码示例。如果您正苦于以下问题:Python PackageManager.add_package方法的具体用法?Python PackageManager.add_package怎么用?Python PackageManager.add_package使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openalea.core.pkgmanager.PackageManager
的用法示例。
在下文中一共展示了PackageManager.add_package方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_recursion_factory
# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import add_package [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
示例2: test_compositenodeio
# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import add_package [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.
示例3: test_export
# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import add_package [as 别名]
def test_export():
"""test export"""
d= {}
execfile('catalog.py', globals(), d)
pkg = d['pkg']
plus_node= pkg['plus'].instantiate()
float_node= pkg['float'].instantiate()
int_node= pkg['int'].instantiate()
string_node= pkg['string'].instantiate()
pm = PackageManager()
pm.add_package(pkg)
sg = CompositeNode()
# build the compositenode factory
addid = sg.add_node(plus_node)
val1id = sg.add_node(float_node)
val2id = sg.add_node(float_node)
val3id = sg.add_node(float_node)
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)
export_app.export_app("ADD", "app.py", sgfactory)
f = open("app.py")
assert f
import app
# requires X server
# app.main(sys.argv)
f.close()
os.remove("app.py")
try:
os.remove("app.pyc")
except:
pass
示例4: setUp
# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import add_package [as 别名]
class TestClass:
def setUp(self):
d= {}
execfile('catalog.py', globals(), d)
self.pkg = d['pkg']
self.plus_node= self.pkg['plus'].instantiate()
self.float_node= self.pkg['float'].instantiate()
self.int_node= self.pkg['int'].instantiate()
self.string_node= self.pkg['string'].instantiate()
self.pm = PackageManager()
self.pm.add_package(self.pkg)
def test_instantiate_compositenode(self):
"""test instantiation"""
#pm = PackageManager()
#pm.init()
sg = CompositeNode()
# build the compositenode factory
addid = sg.add_node(self.plus_node)
val1id = sg.add_node(self.float_node)
val2id = sg.add_node(self.float_node)
val3id = sg.add_node(self.float_node)
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.
def test_compositenode_creation_without_edges(self):
"""test compositenode creation without edges"""
sg = CompositeNode()
# build the compositenode factory
addid = sg.add_node(self.plus_node)
val1id = sg.add_node(self.float_node)
val2id = sg.add_node(self.float_node)
val3id = sg.add_node(self.float_node)
sgfactory = CompositeNodeFactory("addition")
sg.to_factory(sgfactory)
# allocate the compositenode
sg = sgfactory.instantiate()
assert len(sg) == 4+2
def test_to_factory(self):
""" Create a compositenode, generate its factory and reintantiate it """
sg = CompositeNode()
n1 = self.float_node
n2 = self.float_node
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 sg, sgfactory
def test_to_factory2(self):
""" test factory """
sg, sgfactory= self.test_to_factory()
sg.to_factory(sgfactory)
sg2= sgfactory.instantiate()
assert len(sg)==len(sg2)
#.........这里部分代码省略.........