brian-team/brian2 — pull request #208 by mstimberg (2014-02-05 16:37:10+00:00)
Title: Group refactoring

So I moved again some stuff around, variable setting goes now back to `Group` and the standalone device uses the `@device_override` mechanism to overwrite stuff related to numerical indexing (closes #202). I also turned all monitors into `Group` classes (that are `CodeRunner` at the same time). To get everything work properly with standalone I had to actually do quite an intrusive change and finally fix the handling of `AttributeVariable` values. This means that `t` and `dt` no longer have a special status in standalone, the code objects run functions also no longer get a `t` argument (to make this work consistently, it is expected that an attribute corresponds to a *method* of the class, i.e. I had to introduce inline methods for `dt` and `N` in the synapses class). This closes #203.

From my side this is again ready-to-merge. Some remarks:
* Since they now inherit from `Group`, we now have the full power of our standard state variable mechanism in monitors, e.g. you can use string-based expressions. This is very limited at the moment, though (the only useful working thing at the moment is time-based expressions, i.e. writing `spikemon.i['t>50*ms']` instead of `spikemon.i[spikemon.t>50*ms]`). I filed an issue (#207) about this, maybe we can make it more powerful.
* Given that monitors are now standard groups, I also removed their special write functions -- you'll now get e.g. the times of a `SpikeMonitor` as `_dynamic_array_spikemonitor_i` instead of `spikemonitor_codeobject_i`. Only for `StateMonitor` this is not very nice, since the variable is called `_dynamic_array__recorded_varname`... We could make this nicer by using `varname` in `StateMonitor` for the recorded value and use a pre- or postfix for all variables in the source group, e.g. `varname_source`.
* With all the recent changes, implementing the loading part of #177 should be fairly easy now. We could set a flag after `build` (with `run=True`) has been executed and then we could have the standalone device load variables on demand. I don't think we need any special solution for monitors.