def test_RandomDivergentConnect(self): """RandomDivergentConnect""" cynest.ResetKernel() a=cynest.Create("iaf_neuron", 1000) source=[1] targets=range(2,1000) cynest.RandomDivergentConnect(source,targets, 500, [1.0], [1.0]) conn1=cynest.GetConnections(source) self.assertEqual(len(conn1), 500)
def test_RandomConvergentConnect(self): """RandomConvergentConnect""" cynest.ResetKernel() a=cynest.Create("iaf_neuron", 1000) sources=list(range(2,1000)) target=[1] cynest.RandomConvergentConnect(sources,target, 500, [1.0], [1.0]) conn1=cynest.GetConnections(sources) self.assertEqual(len(conn1), 500)
def connPlot(spop, smod, tmod, syn, titl): '''Plot connections. spop, smod source population and model tmod target model syn synapse type titl figure title''' # center location, cast to int since ``pyreport`` makes all div double ctr = [int(Params["N"] / 2), int(Params["N"] / 2)] # get element at center src = topo.GetElement(spop, ctr) # if center element is not individual neuron, find one # neuron of desired model in center element if nest.GetStatus(src, 'model')[0] == 'subnet': src = [ n for n in nest.GetLeaves(src)[0] if nest.GetStatus([n], 'model')[0] == smod ][:1] # get position (in degrees) of chosen source neuron srcpos = topo.GetPosition(src) # get all targets tgts = nest.GetConnections(src, syn)[0]['targets'] # pick targets of correct model type, get their positions, # convert list of (x,y) pairs to pair of x- and y-lists pos = zip(*[ topo.GetPosition([n]) for n in tgts if nest.GetStatus([n], 'model')[0] == tmod ]) # plot source neuron in red, slightly larger, targets on blue pylab.clf() pylab.plot(pos[0], pos[1], 'bo', markersize=5, zorder=99, label='Targets') pylab.plot(srcpos[:1], srcpos[1:], 'ro', markersize=10, markeredgecolor='r', zorder=1, label='Source') axsz = Params['visSize'] / 2 + 0.2 pylab.axis([-axsz, axsz, -axsz, axsz]) pylab.title(titl) pylab.legend() # pylab.show() required for `pyreport` pylab.show()
def test_DivergentConnect(self): """DivergentConnect""" cynest.ResetKernel() a=cynest.Create("iaf_neuron", 10) source=[1] targets=[1 * x for x in list(range(2,11))] cynest.DivergentConnect(source, targets, [1.0], [1.0]) conn1=cynest.GetConnections(source) stat1=cynest.GetStatus(conn1) target1=[ d['target'] for d in stat1] self.assertEqual(targets, target1)
def test_ConvergentConnect(self): """ConvergentConnect""" cynest.ResetKernel() a=cynest.Create("iaf_neuron", 10) target=[1] sources=[1 * x for x in list(range(2,11))] cynest.ConvergentConnect(sources, target, [1.0], [1.0]) conn1=cynest.GetConnections(sources) stat1=cynest.GetStatus(conn1) target1=[ d['source'] for d in stat1] self.assertEqual(sources, target1)
def test_DataConnect2(self): """DataConnect""" cynest.ResetKernel() a=cynest.Create("iaf_neuron", 100000) sources=[1] target=[x for x in list(range(2,100000))] weight=[2.0 * x for x in target] delay=[1.0 * x for x in target] connections=[{'target':target, 'weight':weight, 'delay':delay} for t in target ] cynest.DataConnect(sources,connections, "static_synapse", 2) conn1=cynest.GetConnections(sources) stat1=cynest.GetStatus(conn1) target1=[ d['target'] for d in stat1] self.assertEqual(target, target1)