Debian Codegraph @

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

raw
1 {# USES_VARIABLES { N } #}
2 {# ITERATE_ALL { _idx } #}
3 {# t, not_refractory and lastspike are added as needed_variables in the
4 Thresholder class, we cannot use the USES_VARIABLE mechanism
5 conditionally
6 Same goes for "eventspace" (e.g. spikespace) which depends on the type of
7 event #}
8 {% extends 'common_group.py_' %}
9
10 {% block addcode %}
11 {% endblock %}
12
13 {% block maincode %}
14 numpy_True = _numpy.bool_(True)
15 numpy_False = _numpy.bool_(False)
16
17 # scalar code
18 _vectorisation_idx = 1
19 {{scalar_code|autoindent}}
20
21 # vector code
22 _vectorisation_idx = LazyArange(N)
23
24 {{vector_code|autoindent}}
25 if _cond is True or _cond is numpy_True:
26 _events = _numpy.arange(N)
27 elif _cond is False or _cond is numpy_False:
28 _events = _numpy.array([])
29 else:
30 _events, = _cond.nonzero()
31
32 {# Get the name of the array that stores these events (e.g. the spikespace array) #}
33 {% set _eventspace = get_array_name(eventspace_variable) %}
34
35 {{_eventspace}}[-1] = len(_events)
36 {{_eventspace}}[:len(_events)] = _events
37 {% if _uses_refractory %}
38 # Set the neuron to refractory
39 {{not_refractory}}[_events] = False
40 {{lastspike}}[_events] = {{t}}
41 {% endif %}
42 {% endblock %}
43
44 {% block after_code %}
45 {% set _eventspace = get_array_name(eventspace_variable) %}
46 {{_eventspace}}[-1] = 0
47 {% endblock %}