Skip to content

Commit b36b6a6

Browse files
authored
Merge pull request #3684 from jessica-mitchell/test_pp_psc_delta
Update test_pp_psc_delta.py and remove sli version
2 parents 32f0390 + 8f867bd commit b36b6a6

File tree

2 files changed

+80
-443
lines changed

2 files changed

+80
-443
lines changed

testsuite/pytests/test_pp_psc_delta.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,86 @@ def test_adapting_threshold(self):
188188
self.assertLessEqual(-1.0, isi_corr)
189189
self.assertLessEqual(isi_corr, 0.0)
190190

191+
def test_compare_adaptation_and_self_inhibition(self):
192+
"""
193+
Check if threshold adaptation with membrane time constant corresponds to an
194+
inhibitory self-connection.
195+
"""
196+
197+
# test parameters
198+
d = 0.001
199+
lam = 10.0
200+
T = 200000.0
201+
tau_m = 25.0
202+
J_self = 50.0
203+
J_adapt = 0.1
204+
err = 0.2
205+
206+
nest.ResetKernel()
207+
208+
# create a neuron where adaptation does the reset, and one where a
209+
# synapse does.
210+
nrn1 = nest.Create("pp_psc_delta")
211+
nrn2 = nest.Create("pp_psc_delta")
212+
213+
params1 = {
214+
"tau_m": tau_m,
215+
"C_m": 250.0,
216+
"dead_time": d,
217+
"dead_time_random": False,
218+
"dead_time_shape": 1,
219+
"with_reset": False,
220+
"tau_sfa": [300.0, tau_m],
221+
"q_sfa": [J_adapt, J_self],
222+
"c_1": 0.0,
223+
"c_2": lam,
224+
"c_3": 1.0,
225+
"I_e": 0.0,
226+
"t_ref_remaining": 0.0,
227+
}
228+
229+
params2 = {
230+
"tau_m": tau_m,
231+
"C_m": 250.0,
232+
"dead_time": d,
233+
"dead_time_random": False,
234+
"dead_time_shape": 1,
235+
"with_reset": False,
236+
"tau_sfa": 300.0,
237+
"q_sfa": J_adapt,
238+
"c_1": 0.0,
239+
"c_2": lam,
240+
"c_3": 1.0,
241+
"I_e": 0.0,
242+
"t_ref_remaining": 0.0,
243+
}
244+
245+
nest.SetStatus(nrn1, params1)
246+
nest.SetStatus(nrn2, params2)
247+
248+
sr1 = nest.Create("spike_recorder")
249+
sr2 = nest.Create("spike_recorder")
250+
251+
nest.Connect(nrn1, sr1)
252+
nest.Connect(nrn2, sr2)
253+
254+
# Set up self-inhibitory connection for nrn2
255+
nest.SetDefaults("static_synapse", {"weight": -1.0 * J_self, "delay": 1.0})
256+
nest.Connect(nrn2, nrn2)
257+
258+
nest.Simulate(T)
259+
260+
n1 = nest.GetStatus(sr1)[0]["n_events"]
261+
n2 = nest.GetStatus(sr2)[0]["n_events"]
262+
263+
ratio = float(n1) / float(n2)
264+
265+
# This could fail due to bad luck. However, if it passes once,
266+
# then it should always do so, since the random numbers are
267+
# reproducible in NEST.
268+
self.assertLess(1.0 - err, ratio)
269+
self.assertLess(ratio, 1.0 + err)
270+
191271

192272
def suite():
193273
suite = unittest.makeSuite(PpPscDeltaTestCase, "test")

0 commit comments

Comments
 (0)