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


Python simulation.Simulation类代码示例

本文整理汇总了Python中topo.base.simulation.Simulation的典型用法代码示例。如果您正苦于以下问题:Python Simulation类的具体用法?Python Simulation怎么用?Python Simulation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_state_stack

 def test_state_stack(self):
     s = Simulation()
     s['pulse1'] = PulseGenerator(period = 1)
     s['pulse2'] = PulseGenerator(period = 3)
     s['sum_unit'] = SumUnit()
     s.connect('pulse1','sum_unit',delay=1)
     s.connect('pulse2','sum_unit',delay=1)
     s.run(1.0)
     s.state_push()
     self.assertEqual(len(s._events_stack),1)
     s.state_pop()
     self.assertEqual(len(s._events_stack),0)
开发者ID:wiktor-b,项目名称:topographica,代码行数:12,代码来源:testsimulation.py

示例2: test_state_stack

 def test_state_stack(self):
     s = Simulation()
     s["pulse1"] = PulseGenerator(period=1)
     s["pulse2"] = PulseGenerator(period=3)
     s["sum_unit"] = SumUnit()
     s.connect("pulse1", "sum_unit", delay=1)
     s.connect("pulse2", "sum_unit", delay=1)
     s.run(1.0)
     s.state_push()
     self.assertEqual(len(s._events_stack), 1)
     s.state_pop()
     self.assertEqual(len(s._events_stack), 0)
开发者ID:sf-issues,项目名称:topographica,代码行数:12,代码来源:testsimulation.py

示例3: setUp

 def setUp(self):
     self.original_output_path = normalize_path.prefix
     normalize_path.prefix = tempfile.mkdtemp()
     self.sim = Simulation(register=True,name="testplotfilesaver")
     self.sim['A'] = GeneratorSheet(nominal_density=2)
     self.sim['B'] = CFSheet(nominal_density=2)
     self.sim.connect('A','B',connection_type=CFProjection,name='Afferent')
开发者ID:AnthonyAlers,项目名称:topographica,代码行数:7,代码来源:testplotfilesaver.py

示例4: test_get_objects

    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,代码行数:17,代码来源:testsimulation.py

示例5: test_get_objects

    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,代码行数:17,代码来源:testsimulation.py

示例6: setUp

    def setUp(self):

        self.sim = Simulation()

        self.sim['Dest'] = CFSheet(nominal_density=10,nominal_bounds=BoundingBox(radius=0.5))
        self.sim['Src'] = CFSheet(nominal_density=10,nominal_bounds=BoundingBox(radius=0.5))

        self.sim.connect('Src','Dest',
                         connection_type = ResizableCFProjection,
                         )
开发者ID:AnthonyAlers,项目名称:topographica,代码行数:10,代码来源:testcf.py

示例7: TestPlotGroupSaverBase

class TestPlotGroupSaverBase(unittest.TestCase):

    def exists(self,name):
        target = os.path.join(normalize_path.prefix,name)
        files = glob.glob(os.path.join(normalize_path.prefix,"*"))
        self.assert_(os.path.exists(target),
                     "'%s' not among '%s'"%(os.path.basename(target),
                                            [os.path.basename(f) for f in files]))

    def setUp(self):
        self.original_output_path = normalize_path.prefix
        normalize_path.prefix = tempfile.mkdtemp()
        self.sim = Simulation(register=True,name="testplotfilesaver")
        self.sim['A'] = GeneratorSheet(nominal_density=2)
        self.sim['B'] = CFSheet(nominal_density=2)
        self.sim.connect('A','B',connection_type=CFProjection,name='Afferent')

    def tearDown(self):
        shutil.rmtree(normalize_path.prefix)
        normalize_path.prefix = self.original_output_path
开发者ID:AnthonyAlers,项目名称:topographica,代码行数:20,代码来源:testplotfilesaver.py

示例8: _initialize

def _initialize():
    """Make a simple simulation."""
    from topo.base.simulation import Simulation
    from topo.base.cf import CFSheet,CFProjection
    from topo.sheet import GeneratorSheet

    sim=Simulation(register=True,name="test pattern tester")
    sim['GS']=GeneratorSheet(nominal_density=2)
    sim['GS2']=GeneratorSheet(nominal_density=2)
    sim['S'] = CFSheet(nominal_density=2)
    sim['S2'] = CFSheet(nominal_density=2)
    sim.connect('GS','S',connection_type=CFProjection,delay=0.05)
    sim.connect('GS','S2',connection_type=CFProjection,delay=0.05)
    sim.connect('GS2','S2',connection_type=CFProjection,delay=0.05)
开发者ID:bilal-khan,项目名称:topographica,代码行数:14,代码来源:gui_tests.py

示例9: new_simulation

def new_simulation(name=None,register=True):

    from topo.base.simulation import Simulation
    from topo.base.cf import CFSheet,CFProjection
    from topo.sheet import GeneratorSheet
    from topo.base.boundingregion import BoundingBox

    sim=Simulation(register=register,name=name)
    b= BoundingBox(radius=0.5)
    sim['GS']=GeneratorSheet(nominal_density=2,nominal_bounds=b)
    sim['GS2']=GeneratorSheet(nominal_density=2,nominal_bounds=b)
    sim['S'] = CFSheet(nominal_density=2,nominal_bounds=b)
    sim['S2'] = CFSheet(nominal_density=2,nominal_bounds=b)
    sim.connect('GS','S',connection_type=CFProjection,delay=0.05)
    sim.connect('GS','S2',connection_type=CFProjection,delay=0.05)
    sim.connect('GS2','S2',connection_type=CFProjection,delay=0.05)
    return sim
开发者ID:AnthonyAlers,项目名称:topographica,代码行数:17,代码来源:utils.py

示例10: test_event_insert

    def test_event_insert(self):
        s = Simulation()

        e1 = Event(1)
        e1a = Event(1)
        e2 = Event(2)
        e2a = Event(2)

        s.enqueue_event(e1)
        s.enqueue_event(e2)
        s.enqueue_event(e2a)
        s.enqueue_event(e1a)

        s.enqueue_event(Event(0))

        assert len(s.events) == 5, 'Event queue has %d events, should have 5.' % len(s.events)

        assert s.events[1] == e1
        assert s.events[2] == e1a
        assert s.events[3] == e2
        assert s.events[4] == e2a
开发者ID:wiktor-b,项目名称:topographica,代码行数:21,代码来源:testsimulation.py

示例11: TestCFIter

class TestCFIter(unittest.TestCase):

    iter_type = CFIter

    def setUp(self):

        self.sim = Simulation()

        self.sim['Dest'] = CFSheet(nominal_density=10,nominal_bounds=BoundingBox(radius=0.5))
        self.sim['Src'] = CFSheet(nominal_density=10,nominal_bounds=BoundingBox(radius=0.5))

        self.sim.connect('Src','Dest',
                         connection_type = ResizableCFProjection,
                         )

    def test_iterate_all(self):
        """
        Test to make sure the iterator hits every CF
        """
        total = 0
        dest = self.sim['Dest']
        proj = dest.projections()['SrcToDest']
        rows,cols = dest.shape
        iterator = self.iter_type(proj)
        for cf,i in iterator():
            total += 1
            self.failUnless(0 <= i < 100, "CFIter generated bogus CF index")
            cfxy = (proj.X_cf.flat[i],proj.Y_cf.flat[i])
            r,c = i/cols,i%cols
            self.failUnlessEqual(cfxy,dest.matrixidx2sheet(r,c))
        self.failUnlessEqual(total,100)


    def test_iterate_some_nil(self):
        """
        Test to make sure iterator skips nil CFs (i.e cf == None)
        """
        dest = self.sim['Dest']
        proj = dest.projections()['SrcToDest']
        total = 0
        proj.flatcfs[24] = None
        for cf,i in self.iter_type(proj)():
            total += 1
            self.failIfEqual(i,24)
        self.failUnlessEqual(total,99)


    def test_iterate_masked(self):
        """
        Test if iterator skips masked CFs
        """
        total = 0
        dest = self.sim['Dest']
        proj = dest.projections()['SrcToDest']
        dest.mask.data = numpy.zeros(dest.activity.shape)
        dest.mask.data.flat[24] = 1
        for cf,i in self.iter_type(proj)():
            total += 1
            self.failUnlessEqual(i,24)
            self.failUnless(cf is proj.flatcfs[24])
        self.failUnlessEqual(total,1)
开发者ID:AnthonyAlers,项目名称:topographica,代码行数:61,代码来源:testcf.py


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