def set_initial_value(self, variable, value, selector=None): """ See AbstractPopulationInitializable.set_initial_value """ if not self._vertex_population_initializable: raise KeyError( "Population does not support the initialisation of {}".format( variable)) if globals_variables.get_not_running_simulator().has_ran \ and not self._vertex_changeable_after_run: raise Exception("Population does not support changes after run") self._vertex.set_initial_value(variable, value, selector)
def _initialize(self, variable, value): """ Set the initial value of one of the state variables of the neurons\ in this population. """ if not self._vertex_population_initializable: raise KeyError( "Population does not support the initialisation of {}".format( variable)) if globals_variables.get_not_running_simulator().has_ran \ and not self._vertex_changeable_after_run: raise Exception("Population does not support changes after run") self._vertex.initialize(variable, value)
def _initialize(self, variable, value): """ Set the initial value of one of the state variables of the neurons\ in this population. """ if not self._vertex_population_initializable: raise KeyError( "Population does not support the initialisation of {}".format( variable)) if globals_variables.get_not_running_simulator().has_ran \ and not self._vertex_changeable_after_run: raise Exception("Population does not support changes after run") self._vertex.initialize(variable, value)
def Population(size, cellclass, cellparams, structure=None, label=None): """ building a new pop :param size: n neurons :param cellclass: the neuron class that needs to be created :param cellparams: the params to put into the neuron model :param structure: ?????? :param label: the human readable label :return: a new population object """ globals_variables.get_simulator().verify_not_running() return globals_variables.get_not_running_simulator().create_population( size, cellclass, cellparams, structure, label)
def _initialize(self, variable, value): """ Set the initial value of one of the state variables of the neurons\ in this population. :param str variable: :param value: :type value: float or int or list(float) or list(int) """ if not self._vertex_population_initializable: raise KeyError( "Population does not support the initialisation of {}".format( variable)) if globals_variables.get_not_running_simulator().has_ran \ and not self._vertex_changeable_after_run: raise Exception("Population does not support changes after run") self._read_parameters_before_set() self.__vertex.initialize(variable, value)
def set_number_of_neurons_per_core(neuron_type, max_permitted): """ Sets a ceiling on the number of neurons of a given type that can be\ placed on a single core. :param neuron_type: the neuron type that will have its max atoms set :param max_permitted: The max amount of atoms to be set :type neuron_type: The string reprensetation of the neuron type :type max_permitted: int :rtype: None """ if not __inspect.isclass(neuron_type): if neuron_type in globals(): neuron_type = globals()[neuron_type] else: raise Exception("Unknown Vertex Type {}".format(neuron_type)) simulator = globals_variables.get_not_running_simulator() simulator.set_number_of_neurons_per_core(neuron_type, max_permitted)
def Projection(presynaptic_population, postsynaptic_population, connector, source=None, target='excitatory', synapse_dynamics=None, label=None, rng=None): """ builds a new projection object :param presynaptic_population: the source pop :param postsynaptic_population: the dest pop :param connector: the connector describing connecitivty :param source: ?????????? :param target: type of synapse, exicitiatory or inhibitoary for example. :param synapse_dynamics: plasticity :param label: human readable label :param rng: random number generator if needed :return: a new Projection object """ globals_variables.get_simulator().verify_not_running() return globals_variables.get_not_running_simulator().create_projection( presynaptic_population, postsynaptic_population, connector, source, target, synapse_dynamics, label, rng)
def _set_check(self, parameter, value): """ Checks for various set methods. """ if not self._vertex_population_settable: raise KeyError( "Population does not have property {}".format(parameter)) if globals_variables.get_not_running_simulator().has_ran \ and not self._vertex_changeable_after_run: raise Exception(" run has been called") if isinstance(parameter, string_types): if value is None: raise Exception("A value (not None) must be specified") elif type(parameter) is not dict: raise Exception( "Parameter must either be the name of a single parameter to" " set, or a dict of parameter: value items to set") self._read_parameters_before_set()
def set(self, parameter, value=None): """ Set one or more parameters for every cell in the population. param can be a dict, in which case value should not be supplied, or a\ string giving the parameter name, in which case value is the parameter\ value. value can be a numeric value, or list of such\ (e.g. for setting spike times):: p.set("tau_m", 20.0). p.set({'tau_m':20, 'v_rest':-65}) :param parameter: the parameter to set :type parameter: str or dict :param value: the value of the parameter to set. """ if not self._vertex_population_settable: raise KeyError( "Population does not have property {}".format(parameter)) if globals_variables.get_not_running_simulator().has_ran \ and not self._vertex_changeable_after_run: raise Exception( "This population does not support changes to settings after" " run has been called") if isinstance(parameter, str): if value is None: raise Exception("A value (not None) must be specified") self._read_parameters_before_set() self._vertex.set_value(parameter, value) return if not isinstance(parameter, dict): raise Exception( "Parameter must either be the name of a single parameter to" " set, or a dict of parameter: value items to set") # set new parameters self._read_parameters_before_set() for _key, _value in parameter.iteritems(): self._vertex.set_value(_key, _value)
def _set_check(self, parameter, value): """ Checks for various set methods. """ if not self._vertex_population_settable: raise KeyError("Population does not have property {}".format( parameter)) if globals_variables.get_not_running_simulator().has_ran \ and not self._vertex_changeable_after_run: raise Exception( " run has been called") if isinstance(parameter, string_types): if value is None: raise Exception("A value (not None) must be specified") elif type(parameter) is not dict: raise Exception( "Parameter must either be the name of a single parameter to" " set, or a dict of parameter: value items to set") self._read_parameters_before_set()
def reset(): """ Reset the time to zero, and start the clock. """ globals_variables.get_not_running_simulator().reset()