def __setattr__(self, name, value): " Method called when setting an attribute." Population.__setattr__(self, name, value) if name in ['rates', 'corr', 'tau'] and hasattr(self, 'initialized'): # Correction of mu and sigma everytime r, c or tau is changed self.mu, self.sigma = self._rectify(self.rates, self.corr, self.tau)
def __setattr__(self, name, value): if name == 'spike_times': if self.initialized: self.cyInstance.set_spike_times(value) else: object.__setattr__(self, name, value) else: Population.__setattr__(self, name, value)
def __setattr__(self, name, value): if name == 'spike_times': if not isinstance(value[0], list): # several neurons value = [ value ] if not len(value) == self.size: Global._error('SpikeSourceArray: the size of the spike_times attribute must match the number of neurons in the population.') self.init['spike_times'] = value # when reset is called if self.initialized: self.cyInstance.set_spike_times(self._sort_spikes(value)) else: Population.__setattr__(self, name, value)
def __setattr__(self, name, value): if name == 'spike_times': if not isinstance(value[0], list): # several neurons value = [value] if not len(value) == self.size: Global._error( 'SpikeSourceArray: the size of the spike_times attribute must match the number of neurons in the population.' ) self.init['spike_times'] = value # when reset is called if self.initialized: self.cyInstance.set_spike_times(self._sort_spikes(value)) else: Population.__setattr__(self, name, value)
def __setattr__(self, name, value): if name == 'schedule': if self.initialized: self.cyInstance.set_schedule( np.array(value) / Global.config['dt'] ) else: self.init['schedule'] = value elif name == 'rates': if self.initialized: if len(value.shape) > 2: # we need to flatten the provided data flat_values = value.reshape( (value.shape[0], self.size) ) self.cyInstance.set_rates( flat_values ) else: self.cyInstance.set_rates( value ) else: self.init['rates'] = value elif name == "period": if self.initialized: self.cyInstance.set_period(int(value /Global.config['dt'])) else: self.init['period'] = value else: Population.__setattr__(self, name, value)
def __setattr__(self, name, value): if name == 'schedule': if self.initialized: self.cyInstance.set_schedule( np.array(value) / Global.config['dt']) else: self.init['schedule'] = value elif name == 'rates': if self.initialized: if len(value.shape) > 2: # we need to flatten the provided data flat_values = value.reshape((value.shape[0], self.size)) self.cyInstance.set_rates(flat_values) else: self.cyInstance.set_rates(value) else: self.init['rates'] = value elif name == "period": if self.initialized: self.cyInstance.set_period(int(value / Global.config['dt'])) else: self.init['period'] = value else: Population.__setattr__(self, name, value)