def test_GetLayer(self): """Check if GetLayer returns correct information.""" nr = 4 nc = 5 ldict = {'elements': 'iaf_neuron', 'rows': nr, 'columns': nc} nlayers = 3 nest.ResetKernel() l = topo.CreateLayer((ldict, ) * nlayers) # obtain list containing list of results from GetLayer for all # nodes in layers leavelayers = [topo.GetLayer(node) for node in nest.GetLeaves(l)] # the list comprehension builds a list of lists of layer gids, # each list containing nr*nc copies of the layer gid self.assertEqual([list(t) for t in zip(*([l] * (nr * nc)))], leavelayers)
def test_GetLayer(self): """Check if GetLayer returns correct information.""" nr = 4 nc = 5 ldict = {'elements': 'iaf_psc_alpha', 'rows': nr, 'columns': nc} nlayers = 3 nest.ResetKernel() l = topo.CreateLayer((ldict, ) * nlayers) # obtain list containing list of results from GetLayer for all # nodes in layers layers_exp = (topo.GetLayer(node) for node in nest.GetLeaves(l)) # the list comprehension builds a list of lists of layer gids, # each list containing nr*nc copies of the layer gid layers_ref = zip(*((l, ) * (nr * nc))) for le, lr in zip(layers_exp, layers_ref): self.assertEqual(le, lr)