Skip to content

Commit

Permalink
Give SpikeMonitor.i, t and count a groupname and make them ArrayVariable
Browse files Browse the repository at this point in the history
rather than Variable
  • Loading branch information
thesamovar committed Sep 8, 2013
1 parent 9523444 commit e34eb36
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
3 changes: 1 addition & 2 deletions brian2/devices/cpp_standalone/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def build(self, net):
# Write the arrays
array_specs = [(k, c_data_type(v.dtype), len(v)) for k, v in self.arrays.iteritems()]
dynamic_array_specs = [(k, c_data_type(v.dtype)) for k, v in self.dynamic_arrays.iteritems()]
print self.dynamic_arrays.keys()
arr_tmp = CPPStandaloneCodeObject.templater.arrays(None, array_specs=array_specs,
dynamic_array_specs=dynamic_array_specs)
open('output/arrays.cpp', 'w').write(arr_tmp.cpp_file)
Expand All @@ -99,7 +98,7 @@ def build(self, net):
code_object_defs = defaultdict(list)
for codeobj in self.code_objects.values():
for k, v in codeobj.nonconstant_values:
if k=='t' or k=='_spikes' or k=='_num_spikes':
if k=='t':
pass
elif v.im_class is ArrayVariable:
# find the corresponding array
Expand Down
2 changes: 2 additions & 0 deletions brian2/devices/cpp_standalone/templates/arrays.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% macro cpp_file() %}

#include<stdint.h>
#include<vector>
#include "arrays.h"

// static arrays
Expand All @@ -22,6 +23,7 @@ std::vector<{{dtype_spec}}> {{varname}};
#ifndef _BRIAN_ARRAYS_H
#define _BRIAN_ARRAYS_H

#include<vector>
#include<stdint.h>

// static arrays
Expand Down
7 changes: 3 additions & 4 deletions brian2/monitors/spikemonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ def __init__(self, source, record=True, when=None, name='spikemonitor*',
# DynamicArray here, having access to the underlying
# array is not enough since we want to do the resize
# in the template
'_i': Variable(Unit(1), self._i),
'_t': Variable(Unit(1), self._t),
'_count': ArrayVariable('_count', Unit(1),
self.count),
'_i': ArrayVariable('_i', Unit(1), self._i, group_name=self.name),
'_t': ArrayVariable('_t', Unit(1), self._t, group_name=self.name),
'_count': ArrayVariable('_count', Unit(1), self.count, group_name=self.name),
'_source_start': Variable(Unit(1), start,
constant=True),
'_source_end': Variable(Unit(1), end,
Expand Down
6 changes: 3 additions & 3 deletions dev/ideas/devices/cpp_standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
# Use a NeuronGroup to fake the whole process
G = NeuronGroup(N, eqs, reset=reset, threshold=threshold, refractory=refractory, name='gp')
M = SpikeMonitor(G)
G2 = NeuronGroup(1, eqs, reset=reset, threshold=threshold, refractory=refractory, name='gp2')
#G2 = NeuronGroup(1, eqs, reset=reset, threshold=threshold, refractory=refractory, name='gp2')
# Run the network for 0 seconds to generate the code
net = Network(G,
M,
G2,
#M,
#G2,
)

net.run(0*second)
Expand Down
1 change: 1 addition & 0 deletions examples/phase_locking.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from brian2 import *

#brian_prefs.codegen.target = 'weave'
BrianLogger.log_level_debug()

tau = 20 * ms
N = 100
Expand Down

0 comments on commit e34eb36

Please sign in to comment.