Debian Codegraph @

brian2/codegen/runtime/numpy_rt/templates/summed_variable.py_

raw
1 {# USES_VARIABLES { N } #}
2 {# ITERATE_ALL { _idx } #}
3 {% extends 'common_group.py_' %}
4
5 {% block maincode %}
6 {% set _target_var_array = get_array_name(_target_var) %}
7 {% set _index_array = get_array_name(_index_var) %}
8
9 # scalar code
10 _vectorisation_idx = 1
11 {{scalar_code|autoindent}}
12
13 # vector code
14 _vectorisation_idx = LazyArange(N)
15 {{vector_code|autoindent}}
16
17 # We write to the array, using the name provided as a keyword argument to the
18 # template
19 # Note that for subgroups, we do not want to overwrite the full array
20 {% if _target_start > 0 %}
21 _indices = {{_index_array}} - {{_target_start}}
22 {% else %}
23 _indices = {{_index_array}}
24 {% endif %}
25 {# Handle the situation that the target did not have a stop variable, e.g. for synapses: #}
26 {% if _target_stop < 0 %}
27 _target_stop = {{constant_or_scalar(_target_size_name, variables[_target_size_name])}}
28 {% else %}
29 _target_stop = {{_target_stop}}
30 {% endif %}
31 _length = _target_stop - {{_target_start}}
32 {{_target_var_array}}[{{_target_start}}:_target_stop] = _numpy.bincount(_indices,
33 minlength=_length,
34 weights=_numpy.broadcast_to(_synaptic_var, (N, )))
35 {% endblock %}