def testPMapping(self): N = 30 p = 0.5 pyAex.MAPVERS = 3 s = create_default_population(self.nsetup, 'seq', N) t = create_default_population(self.nsetup, 'ifslwta', N) t2 = create_default_population(self.nsetup, 'ifslwta', 124 - N, offset=N) mon = self.nsetup.monitors.import_monitors_otf(t)[0] mon_zero = self.nsetup.monitors.import_monitors_otf(t2)[0] m = pyNCS.PMapping('') m.__connect_random_all2all__(s.soma, t.synapses['excitatory0'], p=p) m.__connect_one2one__(s.soma, t.synapses['excitatory0']) P = int(p * 127) for i in s.soma.paddr: for j in t.synapses['excitatory0'].paddr: self.assert_([i, j, P] in m.mapping) for n in range(len(s.soma.paddr)): self.assert_( [s.soma.paddr[n], t.synapses['excitatory0'].paddr[n], P ] in m.mapping) self.nsetup.mapping.merge(m) self.nsetup.prepare() self.nsetup.chips['ifslwta'].set_parameter('nsynstdw0', .5) input_stim = s.soma.spiketrains_poisson(400) out = self.nsetup.run(input_stim) self.assertTrue( np.all(350 > mon.sl.mean_rates()) and np.all(mon.sl.mean_rates() > 100)) self.assertTrue(np.all(mon_zero.sl.mean_rates() < 2))
def testPMappingLarge(self): N=124 p=0.5 #pyAex.MAPVERS=3 s=create_default_population(self.nsetup, 'seq', N) t=create_default_population(self.nsetup, 'ifslwta', N) m=pyNCS.PMapping('') M = np.random.randint(0,2,size=(len(s.soma),2)) m.mapping.extend(np.random.randint(0,50000,size=(500000,2))) for j in xrange(len(s)): print j m.connect(s.soma[j], t.synapses['inhibitory'][(j*2):((j+1)*2)], fashion = 'by_boolean_matrix', fashion_kwargs={'connection': M[[j],:]})