Skip to content

Commit

Permalink
Merge 2a81d44 into d036012
Browse files Browse the repository at this point in the history
  • Loading branch information
appukuttan-shailesh committed May 6, 2019
2 parents d036012 + 2a81d44 commit 2b7958b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions pyNN/brian/standardmodels/electrodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ def __init__(self, **parameters):

def _generate(self):
# Note: Brian uses seconds as unit of time
temp_num_t = len(numpy.arange(self.start, self.stop + simulator.state.dt * 1e-3, simulator.state.dt * 1e-3))
self.times = numpy.array([self.start+(i*simulator.state.dt*1e-3) for i in range(temp_num_t)])
temp_num_t = int(round(((self.stop + simulator.state.dt * 1e-3) - self.start) / (simulator.state.dt * 1e-3)))
self.times = self.start + (simulator.state.dt * 1e-3) * numpy.arange(temp_num_t)

def _compute(self, time):
# Note: Brian uses seconds as unit of time; frequency is specified in Hz; thus no conversion required
Expand Down Expand Up @@ -217,8 +217,8 @@ def __init__(self, **parameters):
self._generate()

def _generate(self):
temp_num_t = len(numpy.arange(self.start, self.stop, max(self.dt, simulator.state.dt * 1e-3)))
self.times = numpy.array([self.start+(i*max(self.dt, simulator.state.dt * 1e-3)) for i in range(temp_num_t)])
temp_num_t = int(round((self.stop - self.start) / max(self.dt, simulator.state.dt * 1e-3)))
self.times = self.start + max(self.dt, simulator.state.dt * 1e-3) * numpy.arange(temp_num_t)
self.times = numpy.append(self.times, self.stop)

def _compute(self, time):
Expand Down
8 changes: 5 additions & 3 deletions pyNN/neuron/standardmodels/electrodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ def __init__(self, **parameters):
def _generate(self):
# Not efficient at all... Is there a way to have those vectors computed on the fly ?
# Otherwise should have a buffer mechanism
self.times = numpy.arange(self.start, self.stop + simulator.state.dt, simulator.state.dt)
tmp = numpy.arange(0, self.stop - self.start, simulator.state.dt)
temp_num_t = int(round(((self.stop + simulator.state.dt) - self.start) / simulator.state.dt))
tmp = simulator.state.dt * numpy.arange(temp_num_t)
self.times = tmp + self.start
self.amplitudes = self.offset + self.amplitude * numpy.sin(tmp * 2 * numpy.pi * self.frequency / 1000. + 2 * numpy.pi * self.phase / 360)
self.amplitudes[-1] = 0.0

Expand All @@ -238,7 +239,8 @@ def __init__(self, **parameters):
def _generate(self):
## Not efficient at all... Is there a way to have those vectors computed on the fly ?
## Otherwise should have a buffer mechanism
self.times = numpy.arange(self.start, self.stop, max(self.dt, simulator.state.dt))
temp_num_t = int(round((self.stop - self.start) / max(self.dt, simulator.state.dt)))
self.times = self.start + max(self.dt, simulator.state.dt) * numpy.arange(temp_num_t)
self.times = numpy.append(self.times, self.stop)
self.amplitudes = self.mean + self.stdev * numpy.random.randn(len(self.times))
self.amplitudes[-1] = 0.0

0 comments on commit 2b7958b

Please sign in to comment.