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


Python Simulation.objects方法代碼示例

本文整理匯總了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'
開發者ID:wiktor-b,項目名稱:topographica,代碼行數:19,代碼來源:testsimulation.py

示例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"
開發者ID:sf-issues,項目名稱:topographica,代碼行數:19,代碼來源:testsimulation.py


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