def _create_cells(self, cellclass, cellparams, n): """ Create cells in NEURON. `cellclass` -- a PyNN standard cell or a native NEURON cell class that implements an as-yet-undescribed interface. `cellparams` -- a dictionary of cell parameters. `n` -- the number of cells to create """ # this method should never be called more than once # perhaps should check for that assert n > 0, 'n must be a positive integer' celltype = cellclass(cellparams) cell_model = celltype.model cell_parameters = celltype.parameters self.first_id = simulator.state.gid_counter self.last_id = simulator.state.gid_counter + n - 1 self.all_cells = numpy.array( [id for id in range(self.first_id, self.last_id + 1)], simulator.ID) # mask_local is used to extract those elements from arrays that apply to the cells on the current node self._mask_local = self.all_cells % simulator.state.num_processes == simulator.state.mpi_rank # round-robin distribution of cells between nodes for i, (id, is_local) in enumerate(zip(self.all_cells, self._mask_local)): self.all_cells[i] = simulator.ID(id) self.all_cells[i].parent = self if is_local: self.all_cells[i]._build_cell(cell_model, cell_parameters) simulator.initializer.register(*self.all_cells[self._mask_local]) simulator.state.gid_counter += n
def setUp(self): self.id = simulator.ID(984329856) self.id.parent = MockPopulation() self.id._cell = MockCell()