~ubuntu-branches/ubuntu/precise/brian/precise

« back to all changes in this revision

Viewing changes to brian/experimental/codegen/test_threshold.py

  • Committer: Bazaar Package Importer
  • Author(s): Yaroslav Halchenko
  • Date: 2010-11-02 18:19:15 UTC
  • Revision ID: james.westby@ubuntu.com-20101102181915-ivwy29820copccu2
Tags: upstream-1.2.2~svn2229
ImportĀ upstreamĀ versionĀ 1.2.2~svn2229

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from brian import *
 
2
from brian.experimental.codegen.threshold import *
 
3
 
 
4
eqs = Equations('''
 
5
V : volt
 
6
Vt : volt
 
7
''')
 
8
 
 
9
threshold = '''
 
10
    (V>Vt)&(V>Vt)
 
11
'''
 
12
 
 
13
print '**** C CODE *****'
 
14
print generate_c_threshold(eqs, threshold)
 
15
#
 
16
print '**** PYTHON CODE ****'
 
17
print generate_python_threshold(eqs, threshold)
 
18
 
 
19
GP = NeuronGroup(10, eqs, threshold=PythonThreshold(threshold), reset=0 * volt)
 
20
GC = NeuronGroup(10, eqs, threshold=CThreshold(threshold), reset=0 * volt)
 
21
MP = SpikeMonitor(GP)
 
22
MC = SpikeMonitor(GC)
 
23
 
 
24
GP.V[[1, 2, 4, 8]] = 2
 
25
GP.Vt = 1 * volt
 
26
GP.Vt[[2, 8]] = 3
 
27
GC.V[[1, 2, 4, 8]] = 2
 
28
GC.Vt = 1 * volt
 
29
GC.Vt[[2, 8]] = 3
 
30
 
 
31
run(1 * ms)
 
32
 
 
33
print GP.V
 
34
print GP.Vt
 
35
print MP.spikes
 
36
print
 
37
print GC.V
 
38
print GC.Vt
 
39
print MC.spikes