本文整理汇总了Python中topo.base.simulation.Simulation.objects方法的典型用法代码示例。如果您正苦于以下问题:Python Simulation.objects方法的具体用法?Python Simulation.objects怎么用?Python Simulation.objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类topo.base.simulation.Simulation
的用法示例。
在下文中一共展示了Simulation.objects方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_objects
# 需要导入模块: from topo.base.simulation import Simulation [as 别名]
# 或者: from topo.base.simulation.Simulation import objects [as 别名]
def test_get_objects(self):
s = Simulation()
s['pulse1'] = PulseGenerator(period = 1)
s['pulse2'] = PulseGenerator(period = 3)
s['sum_unit'] = SumUnit()
n1 = s['pulse1'].name
n2 = s['pulse2'].name
s.connect('pulse1','sum_unit',delay=1)
s.connect('pulse2','sum_unit',delay=1)
t1 = s.objects()
e1 = [ep for ep in t1.values() if isinstance(ep,PulseGenerator) and ep.name == n1]
t2 = s.objects()
e2 = [ep for ep in t2.values() if isinstance(ep,PulseGenerator) and ep.name == n2]
assert e1.pop().name == n1, 'Object names do not match'
assert e2.pop().name == n2, 'Object names do not match'
示例2: test_get_objects
# 需要导入模块: from topo.base.simulation import Simulation [as 别名]
# 或者: from topo.base.simulation.Simulation import objects [as 别名]
def test_get_objects(self):
s = Simulation()
s["pulse1"] = PulseGenerator(period=1)
s["pulse2"] = PulseGenerator(period=3)
s["sum_unit"] = SumUnit()
n1 = s["pulse1"].name
n2 = s["pulse2"].name
s.connect("pulse1", "sum_unit", delay=1)
s.connect("pulse2", "sum_unit", delay=1)
t1 = s.objects()
e1 = [ep for ep in t1.values() if isinstance(ep, PulseGenerator) and ep.name == n1]
t2 = s.objects()
e2 = [ep for ep in t2.values() if isinstance(ep, PulseGenerator) and ep.name == n2]
assert e1.pop().name == n1, "Object names do not match"
assert e2.pop().name == n2, "Object names do not match"