Skip to content

Commit 0cc153a

Browse files
committed
run combined
1 parent a4570bb commit 0cc153a

1 file changed

Lines changed: 65 additions & 42 deletions

File tree

examples/if_curr_alpha.py

Lines changed: 65 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -15,52 +15,75 @@
1515
import pyNN.utility.plotting as plot
1616
import matplotlib.pyplot as plt
1717

18-
p.setup(0.1)
19-
runtime = 50
20-
populations = []
21-
title = "PyNN0.8 alpha synapse testing"
18+
def run_script(*, split: bool = True) -> None:
19+
"""
20+
Runs the example script
2221
23-
pop_src1 = p.Population(1, p.SpikeSourceArray,
24-
{'spike_times': [[5, 15, 20, 30]]}, label="src1")
22+
The default setting cause this script to split.
2523
26-
populations.append(p.Population(1, p.IF_curr_alpha, {}, label="test"))
24+
:param split: If True will split the Populations that receive data
25+
into synapse and neuron cores.
26+
This requires more cores but allows more spikes to be received.
27+
"""
28+
p.setup(0.1)
29+
runtime = 50
30+
populations = []
31+
title = "PyNN alpha synapse testing"
2732

28-
populations[0].set(tau_syn_E=2)
29-
populations[0].set(tau_syn_I=4)
33+
pop_src1 = p.Population(1, p.SpikeSourceArray,
34+
{'spike_times': [[5, 15, 20, 30]]}, label="src1")
35+
if split:
36+
# Due to the timestep of 0.1 by default
37+
# this splits into synapses and neuron cores
38+
populations.append(p.Population(1, p.IF_curr_alpha, {}, label="test"))
39+
else:
40+
# can be forced to not split this way
41+
populations.append(p.Population(1, p.IF_curr_alpha, {}, label="test",
42+
n_synapse_cores=0))
3043

31-
# define the projections
32-
exc_proj = p.Projection(pop_src1, populations[0],
33-
p.OneToOneConnector(),
34-
p.StaticSynapse(weight=1, delay=1),
35-
receptor_type="excitatory")
36-
inh_proj = p.Projection(pop_src1, populations[0],
37-
p.OneToOneConnector(),
38-
p.StaticSynapse(weight=1, delay=10),
39-
receptor_type="inhibitory")
44+
populations[0].set(tau_syn_E=2)
45+
populations[0].set(tau_syn_I=4)
4046

41-
populations[0].record("all")
42-
p.run(runtime)
47+
# define the projections
48+
exc_proj = p.Projection(pop_src1, populations[0],
49+
p.OneToOneConnector(),
50+
p.StaticSynapse(weight=1, delay=1),
51+
receptor_type="excitatory")
52+
inh_proj = p.Projection(pop_src1, populations[0],
53+
p.OneToOneConnector(),
54+
p.StaticSynapse(weight=1, delay=10),
55+
receptor_type="inhibitory")
4356

44-
v = populations[0].get_data("v")
45-
gsyn_exc = populations[0].get_data("gsyn_exc")
46-
gsyn_inh = populations[0].get_data("gsyn_inh")
47-
spikes = populations[0].get_data("spikes")
57+
populations[0].record("all")
58+
p.run(runtime)
4859

49-
plot.Figure(
50-
plot.Panel(v.segments[0].filter(name='v')[0],
51-
ylabel="Membrane potential (mV)",
52-
data_labels=[populations[0].label],
53-
yticks=True, xlim=(0, runtime)),
54-
plot.Panel(gsyn_exc.segments[0].filter(name='gsyn_exc')[0],
55-
ylabel="gsyn excitatory (mV)",
56-
data_labels=[populations[0].label],
57-
yticks=True, xlim=(0, runtime)),
58-
plot.Panel(gsyn_inh.segments[0].filter(name='gsyn_inh')[0],
59-
ylabel="gsyn inhibitory (mV)",
60-
data_labels=[populations[0].label],
61-
yticks=True, xlim=(0, runtime)),
62-
title=title,
63-
annotations=f"Simulated with {p.name()}"
64-
)
65-
plt.show()
66-
p.end()
60+
v = populations[0].get_data("v")
61+
gsyn_exc = populations[0].get_data("gsyn_exc")
62+
gsyn_inh = populations[0].get_data("gsyn_inh")
63+
spikes = populations[0].get_data("spikes")
64+
65+
plot.Figure(
66+
plot.Panel(v.segments[0].filter(name='v')[0],
67+
ylabel="Membrane potential (mV)",
68+
data_labels=[populations[0].label],
69+
yticks=True, xlim=(0, runtime)),
70+
plot.Panel(gsyn_exc.segments[0].filter(name='gsyn_exc')[0],
71+
ylabel="gsyn excitatory (mV)",
72+
data_labels=[populations[0].label],
73+
yticks=True, xlim=(0, runtime)),
74+
plot.Panel(gsyn_inh.segments[0].filter(name='gsyn_inh')[0],
75+
ylabel="gsyn inhibitory (mV)",
76+
data_labels=[populations[0].label],
77+
yticks=True, xlim=(0, runtime)),
78+
title=title,
79+
annotations=f"Simulated with {p.name()}"
80+
)
81+
plt.show()
82+
p.end()
83+
84+
# combined binaries [IF_curr_alpha.aplx]
85+
# split binaries [IF_curr_alpha_neuron.aplx, synapses.aplx]
86+
87+
88+
if __name__ == "__main__":
89+
run_script()

0 commit comments

Comments
 (0)