def __init__( self, size, cellclass, cellparams=None, structure=None, initial_values=None, label=None, constraints=None, additional_parameters=None): # pylint: disable=too-many-arguments # hard code initial values as required if initial_values is None: initial_values = {} model = cellclass if inspect.isclass(cellclass): if cellparams is None: model = cellclass() else: model = cellclass(**cellparams) elif cellparams: raise ConfigurationException( "cellclass is an instance which includes params so " "cellparams must be None") self._celltype = model # build our initial objects super(Population, self).__init__( spinnaker_control=globals_variables.get_simulator(), size=size, label=label, constraints=constraints, model=model, structure=structure, initial_values=initial_values, additional_parameters=additional_parameters) Recorder.__init__(self, population=self) # annotations used by neo objects self._annotations = dict()
def _record_with_indexes( self, variables, to_file, sampling_interval, indexes): """ Same as record but without non-standard PyNN warning This method is non-standard PyNN and is intended only to be called by\ record in a Population, View or Assembly """ if variables is None: # reset the list of things to record if sampling_interval is not None: raise ConfigurationException( "Clash between parameters in record." "variables=None turns off recording," "while sampling_interval!=None implies turn on recording") if indexes is not None: warn_once( logger, "View.record with variable None is non-standard PyNN. " "Only the neurons in the view have their record turned " "off. Other neurons already set to record will remain " "set to record") # note that if record(None) is called, its a reset Recorder._turn_off_all_recording(self, indexes) # handle one element vs many elements elif isinstance(variables, string_types): # handle special case of 'all' if variables == "all": warn_once( logger, 'record("all") is non-standard PyNN, and ' 'therefore may not be portable to other simulators.') # get all possible recordings for this vertex variables = self._get_all_possible_recordable_variables() # iterate though them for variable in variables: self._record(variable, sampling_interval, to_file, indexes) else: # record variable self._record(variables, sampling_interval, to_file, indexes) else: # list of variables, so just iterate though them for variable in variables: self._record(variable, sampling_interval, to_file, indexes)
def __init__(self, size, cellclass, cellparams=None, structure=None, initial_values=None, label=None): # pylint: disable=too-many-arguments size = self._roundsize(size, label) # hard code initial values as required if initial_values is None: initial_values = {} if isinstance(cellclass, DataHolder): self._vertex_holder = cellclass self._vertex_holder.add_item( 'label', self.create_label( self._vertex_holder.data_items['label'], label)) assert cellparams is None # cellparams being retained for backwards compatibility, but use # is deprecated elif issubclass(cellclass, DataHolder): if cellparams is None: internal_params = dict() else: internal_params = dict(cellparams) cell_label = None if 'label' in internal_params: cell_label = internal_params['label'] internal_params['label'] = self.create_label(cell_label, label) self._vertex_holder = cellclass(**internal_params) # emit deprecation warning else: raise TypeError( "cellclass must be an instance or subclass of BaseCellType," " not a %s" % type(cellclass)) if 'n_neurons' in self._vertex_holder.data_items: if size is None: size = self._vertex_holder.data_items['n_neurons'] elif size != self._vertex_holder.data_items['n_neurons']: raise ConfigurationException( "Size parameter is {} but the {} expects a size of {}" "".format(size, cellclass, self._vertex_holder.data_items['n_neurons'])) else: if size is None: raise ConfigurationException( "Size parameter can not be None for {}".format(cellclass)) self._vertex_holder.add_item('n_neurons', size) # convert between data holder and model (uses ** so that its taken # the dictionary to be the parameters themselves) vertex = self._vertex_holder.build_model()( **self._vertex_holder.data_items) # build our initial objects super(Population, self).__init__( spinnaker_control=globals_variables.get_simulator(), size=size, vertex=vertex, structure=structure, initial_values=initial_values) Recorder.__init__(self, population=self) # annotations used by neo objects self._annotations = dict()