def _insert(self, delay, target): ''' Vectorised insertion of spike events. Parameters ---------- delay : ndarray Delays in timesteps. target : ndarray Target synaptic indices. ''' delay = np.array(delay, dtype=int) offset = calc_repeats(delay) # Calculate row indices in the data structure timesteps = (self.currenttime + delay) % len(self.n) # (Over)estimate the number of events to be stored, to resize the array # It's an overestimation for the current time, but I believe a good one # for future events m = max(self.n) + len(target) if (m >= self.X.shape[1]): # overflow self._resize(m+1) self.X_flat[timesteps*self.X.shape[1]+offset+self.n[timesteps]] = target self.n[timesteps] += offset+1 # that's a trick (to update stack size)
def _insert(self, delay, target): ''' Vectorised insertion of spike events. Parameters ---------- delay : ndarray Delays in timesteps. target : ndarray Target synaptic indices. ''' delay = np.array(delay, dtype=int) offset = calc_repeats(delay) # Calculate row indices in the data structure timesteps = (self.currenttime + delay) % len(self.n) # (Over)estimate the number of events to be stored, to resize the array # It's an overestimation for the current time, but I believe a good one # for future events m = max(self.n) + len(target) if (m >= self.X.shape[1]): # overflow self._resize(m + 1) self.X_flat[timesteps * self.X.shape[1] + offset + self.n[timesteps]] = target self.n[ timesteps] += offset + 1 # that's a trick (to update stack size)