Skip to content

Commit 2e7b26e

Browse files
authored
Merge branch 'master' into make_testable
2 parents 3a58749 + a213a49 commit 2e7b26e

File tree

2 files changed

+0
-137
lines changed

2 files changed

+0
-137
lines changed

examples/pynnBrunnel.py

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -14,80 +14,11 @@
1414

1515
import pyNN.spiNNaker as pynn
1616

17-
import numpy as np
1817
import matplotlib.pyplot as plt
1918
from pyNN.random import RandomDistribution
2019
from pyNN.utility.plotting import Figure, Panel
2120

2221
simulator_Name = 'spiNNaker'
23-
# exec('import pyNN.%s as pynn' % simulator_Name)
24-
25-
26-
def poisson_generator(_rate, _rng, _t_start=0.0, _t_stop=1000.0, _debug=False):
27-
"""
28-
Returns a SpikeTrain whose spikes are a realization of a Poisson process
29-
with the given rate (Hz) and stopping time t_stop (milliseconds).
30-
31-
Note: t_start is always 0.0, thus all realizations are as if
32-
they spiked at t=0.0, though this spike is not included in the SpikeList.
33-
34-
Inputs:
35-
rate - the rate of the discharge (in Hz)
36-
t_start - the beginning of the SpikeTrain (in ms)
37-
t_stop - the end of the SpikeTrain (in ms)
38-
array - if True, a numpy array of sorted spikes is returned,
39-
rather than a SpikeTrain object.
40-
41-
Examples:
42-
>> gen.poisson_generator(50, 0, 1000)
43-
>> gen.poisson_generator(20, 5000, 10000, array=True)
44-
45-
See also:
46-
inh_poisson_generator, inh_gamma_generator,
47-
inh_adaptingmarkov_generator
48-
"""
49-
50-
n = (_t_stop - _t_start) / 1000.0 * _rate
51-
number = np.ceil(n + 3 * np.sqrt(n))
52-
if number < 100:
53-
number = min(5 + np.ceil(2 * n), 100)
54-
55-
if number > 0:
56-
isi = _rng.exponential(1.0 / _rate, number) * 1000.0
57-
if number > 1:
58-
spikes = np.add.accumulate(isi)
59-
else:
60-
spikes = isi
61-
else:
62-
spikes = np.array([])
63-
64-
spikes += _t_start
65-
i = np.searchsorted(spikes, _t_stop)
66-
67-
extra_spikes = []
68-
if i == len(spikes):
69-
# Interspike interval buffer overrun
70-
71-
t_last = spikes[-1] + _rng.exponential(1.0 / _rate, 1)[0] * 1000.0
72-
73-
while (t_last < _t_stop):
74-
extra_spikes.append(t_last)
75-
t_last += _rng.exponential(1.0 / _rate, 1)[0] * 1000.0
76-
77-
spikes = np.concatenate((spikes, extra_spikes))
78-
79-
if _debug:
80-
print(f"ISI buf overrun handled. {len(spikes)=}, "
81-
f"{len(extra_spikes)=}")
82-
83-
else:
84-
spikes = np.resize(spikes, (i,))
85-
86-
if _debug:
87-
return spikes, extra_spikes
88-
else:
89-
return [round(x) for x in spikes]
90-
9122

9223
# Total number of neurons
9324
Neurons = 1000

examples/split_examples/pynnBrunnelSplit.py

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import pyNN.spiNNaker as pynn
1616

17-
import numpy as np
1817
import matplotlib.pyplot as plt
1918
from pyNN.random import RandomDistribution
2019
from pyNN.utility.plotting import Figure, Panel
@@ -23,73 +22,6 @@
2322
# exec('import pyNN.%s as pynn' % simulator_Name)
2423

2524

26-
def poisson_generator(rate, rng, t_start=0.0, t_stop=1000.0, array=True,
27-
debug=False):
28-
"""
29-
Returns a SpikeTrain whose spikes are a realization of a Poisson process
30-
with the given rate (Hz) and stopping time t_stop (milliseconds).
31-
32-
Note: t_start is always 0.0, thus all realizations are as if
33-
they spiked at t=0.0, though this spike is not included in the SpikeList.
34-
35-
Inputs:
36-
rate - the rate of the discharge (in Hz)
37-
t_start - the beginning of the SpikeTrain (in ms)
38-
t_stop - the end of the SpikeTrain (in ms)
39-
array - if True, a numpy array of sorted spikes is returned,
40-
rather than a SpikeTrain object.
41-
42-
Examples:
43-
>> gen.poisson_generator(50, 0, 1000)
44-
>> gen.poisson_generator(20, 5000, 10000, array=True)
45-
46-
See also:
47-
inh_poisson_generator, inh_gamma_generator,
48-
inh_adaptingmarkov_generator
49-
"""
50-
51-
n = (t_stop - t_start) / 1000.0 * rate
52-
number = np.ceil(n + 3 * np.sqrt(n))
53-
if number < 100:
54-
number = min(5 + np.ceil(2 * n), 100)
55-
56-
if number > 0:
57-
isi = rng.exponential(1.0 / rate, number) * 1000.0
58-
if number > 1:
59-
spikes = np.add.accumulate(isi)
60-
else:
61-
spikes = isi
62-
else:
63-
spikes = np.array([])
64-
65-
spikes += t_start
66-
i = np.searchsorted(spikes, t_stop)
67-
68-
extra_spikes = []
69-
if i == len(spikes):
70-
# ISI buf overrun
71-
72-
t_last = spikes[-1] + rng.exponential(1.0 / rate, 1)[0] * 1000.0
73-
74-
while (t_last < t_stop):
75-
extra_spikes.append(t_last)
76-
t_last += rng.exponential(1.0 / rate, 1)[0] * 1000.0
77-
78-
spikes = np.concatenate((spikes, extra_spikes))
79-
80-
if debug:
81-
print("ISI buf overrun handled. len(spikes)=%d,"
82-
" len(extra_spikes)=%d" % (len(spikes), len(extra_spikes)))
83-
84-
else:
85-
spikes = np.resize(spikes, (i,))
86-
87-
if debug:
88-
return spikes, extra_spikes
89-
else:
90-
return [round(x) for x in spikes]
91-
92-
9325
# Total number of neurons
9426
Neurons = 1000
9527
sim_time = 1000.0

0 commit comments

Comments
 (0)