Changeset 385
- Timestamp:
- 06/22/08 16:34:33 (5 months ago)
- Files:
-
- trunk/src/common.py (modified) (2 diffs)
- trunk/src/nest2/__init__.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/common.py
r383 r385 700 700 """ 701 701 702 def __init__(self, dims, cellclass, cellparams=None, label=None, create_cells=True):702 def __init__(self, dims, cellclass, cellparams=None, label=None, parent=None): 703 703 """ 704 704 dims should be a tuple containing the population dimensions, or a single … … 723 723 self.cellparams = cellparams 724 724 self.size = self.dim[0] 725 self.parent = parent 725 726 for i in range(1, self.ndim): 726 727 self.size *= self.dim[i] trunk/src/nest2/__init__.py
r384 r385 530 530 nPop = 0 531 531 532 def __init__(self, dims, cellclass, cellparams=None, label=None, create_cells=True):532 def __init__(self, dims, cellclass, cellparams=None, label=None, parent=None): 533 533 """ 534 534 dims should be a tuple containing the population dimensions, or a single … … 543 543 """ 544 544 545 common.Population.__init__(self, dims, cellclass, cellparams, label, create_cells)545 common.Population.__init__(self, dims, cellclass, cellparams, label, parent) 546 546 547 547 # Should perhaps use "LayoutNetwork"? … … 549 549 if isinstance(cellclass, type): 550 550 self.celltype = cellclass(cellparams) 551 if create_cells:551 if not parent: 552 552 self.cell = nest.Create(self.celltype.nest_name, self.size) 553 553 else: … … 556 556 self.cellparams = self.celltype.parameters 557 557 elif isinstance(cellclass, str): 558 if create_cells:558 if not parent: 559 559 self.cell = nest.Create(cellclass, self.size) 560 560 else: … … 566 566 self.cell = [] 567 567 568 if create_cells:568 if not parent: 569 569 self.cell = numpy.array([ ID(GID) for GID in self.cell ], ID) 570 570 self.cell_local = self.cell[numpy.array(nest.GetStatus(self.cell.tolist(),'local'))] … … 915 915 dims = numpy.array(cell_list).shape 916 916 # We create an empty population 917 pop = Population(dims, cellclass=self.celltype, label=label, create_cells=False)917 pop = Population(dims, cellclass=self.celltype, label=label, parent=self) 918 918 # And then copy parameters from its parent 919 pop.cellparams = self.cellparams920 pop.first_id = self.first_id921 idx = numpy.array(cell_list ).flatten() - pop.first_id922 pop.cell = self.cell.flatten()[idx].reshape(dims)923 pop.cell_local = self.cell_local[idx]924 pop.positions = self.positions[:,idx]919 pop.cellparams = pop.parent.cellparams 920 pop.first_id = pop.parent.first_id 921 idx = numpy.array(cell_list,int).flatten() - pop.first_id 922 pop.cell = pop.parent.cell.flatten()[idx].reshape(dims) 923 pop.cell_local = pop.parent.cell_local[idx] 924 pop.positions = pop.parent.positions[:,idx] 925 925 return pop 926 927 928 929 926 930 927 def describe(self): … … 934 931 print "\n------- Population description -------" 935 932 print "Population called %s is made of %d cells [%d being local]" %(self.label, len(self.cell.flatten()), len(self.cell_local)) 933 if self.parent: 934 print "This population is a subpopulation of population %s" %self.parent.label 936 935 print "-> Cells are aranged on a %dD grid of size %s" %(len(self.dim), self.dim) 937 936 print "-> Celltype is %s" %self.celltype … … 1378 1377 idx = numpy.where(numpy.array(dict['targets']) == self._targets[0])[0] 1379 1378 for key, value in dict.items(): 1380 print "\t| ", key, ": ", value[idx ]1379 print "\t| ", key, ": ", value[idx[0]] 1381 1380 1382 1381 print "---- End of Projection description -----"

