Skip to content

Commit

Permalink
Fixed SpikeMonitor to use _spikespace
Browse files Browse the repository at this point in the history
  • Loading branch information
thesamovar committed Aug 21, 2013
1 parent 7ab5770 commit 35867ed
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions brian2/codegen/runtime/numpy_rt/templates/spikemonitor.py_
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# { USES_VARIABLES _i, _t, _spikes, _count, t, _source_start, _source_end}
# { USES_VARIABLES _i, _t, _spikespace, _count, t, _source_start, _source_end}
import numpy as np
_spikes = _spikespace[:_spikespace[-1]]
# Take subgroups into account
_spikes = np.asarray(_spikes)
_spikes = _spikes[(_spikes >= _source_start) & (_spikes < _source_end)]
_spikes -= _source_start
_n_spikes = len(_spikes)
Expand Down
10 changes: 5 additions & 5 deletions brian2/codegen/runtime/weave_rt/templates/spikemonitor.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% macro main() %}

// USES_VARIABLES { _t, _i, t, _spikes, _count,
// USES_VARIABLES { _t, _i, t, _spikespace, _count,
// _source_start, _source_end}

int _num_spikes = _spikespace[_num_spikespace-1];
if (_num_spikes > 0)
{
// For subgroups, we do not want to record all spikes
Expand All @@ -12,15 +12,15 @@
int _end_idx = - 1;
for(int _i=0; _i<_num_spikes; _i++)
{
const int _idx = _spikes[_i];
const int _idx = _spikespace[_i];
if (_idx >= _source_start) {
_start_idx = _i;
break;
}
}
for(int _i=_start_idx; _i<_num_spikes; _i++)
{
const int _idx = _spikes[_i];
const int _idx = _spikespace[_i];
if (_idx >= _source_end) {
_end_idx = _i;
break;
Expand All @@ -45,7 +45,7 @@
// Copy the values across
for(int _i=_start_idx; _i<_end_idx; _i++)
{
const int _idx = _spikes[_i];
const int _idx = _spikespace[_i];
_t_data[_curlen + _i - _start_idx] = t;
_i_data[_curlen + _i - _start_idx] = _idx - _source_start;
_count[_idx - _source_start]++;
Expand Down
3 changes: 1 addition & 2 deletions brian2/monitors/spikemonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ def __init__(self, source, record=True, when=None, name='spikemonitor*',
end = getattr(self.source, 'end', len(self.source))

self.variables = {'t': AttributeVariable(second, self.clock, 't'),
'_spikes': AttributeVariable(Unit(1), self.source,
'spikes'),
'_spikespace': self.source.variables['_spikespace'],
# The template needs to have access to the
# DynamicArray here, having access to the underlying
# array is not enough since we want to do the resize
Expand Down

0 comments on commit 35867ed

Please sign in to comment.