File: threshold.py_

package info (click to toggle)
brian 2.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,872 kB
  • sloc: python: 51,820; cpp: 2,033; makefile: 108; sh: 72
file content (47 lines) | stat: -rw-r--r-- 1,274 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{# USES_VARIABLES { N } #}
{# ITERATE_ALL { _idx } #}
{# t, not_refractory and lastspike are added as needed_variables in the
  Thresholder class, we cannot use the USES_VARIABLE mechanism
  conditionally
  Same goes for "eventspace" (e.g. spikespace) which depends on the type of
  event #}
{% extends 'common_group.py_' %}

{% block addcode %}
{% endblock %}

{% block maincode %}
numpy_True = _numpy.bool_(True)
numpy_False = _numpy.bool_(False)

# scalar code
_vectorisation_idx = 1
{{scalar_code|autoindent}}

# vector code
_vectorisation_idx = LazyArange(N)

{{vector_code|autoindent}}
if _cond is True or _cond is numpy_True:
    _events = _numpy.arange(N)
elif _cond is False or _cond is numpy_False:
    _events = _numpy.array([])
else:
    _events, = _cond.nonzero()

{#  Get the name of the array that stores these events (e.g. the spikespace array) #}
{% set _eventspace = get_array_name(eventspace_variable) %}

{{_eventspace}}[-1] = len(_events)
{{_eventspace}}[:len(_events)] = _events
{% if _uses_refractory %}
# Set the neuron to refractory
{{not_refractory}}[_events] = False
{{lastspike}}[_events] = {{t}}
{% endif %}
{% endblock %}

{% block after_code %}
{% set _eventspace = get_array_name(eventspace_variable) %}
{{_eventspace}}[-1] = 0
{% endblock %}