Skip to content

Commit

Permalink
add regression test for Issue NeuralEnsemble#563
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz-Alexander-Kern committed May 23, 2023
1 parent dd472e8 commit a988016
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions elephant/test/test_spike_train_correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,50 @@ def test_sttc_edge_cases(self):
self.assertAlmostEqual(target2, sc.sttc(st3, st2, 0.003 * pq.s))
self.assertAlmostEqual(target2, sc.sttc(st2, st3, 0.003 * pq.s))

def test_sttc_unsorted_spiketimes(self):
# regression test for issue #563
# https://github.com/NeuralEnsemble/elephant/issues/563
spiketrain_E7 = neo.SpikeTrain(
[1678., 23786.3, 34641.8, 71520.7, 73606.9, 78383.3,
97387.9, 144313.4, 4607.6, 19275.1, 152894.2, 44240.1],
units='ms', t_stop=160000 * pq.ms)

spiketrain_E3 = neo.SpikeTrain(
[1678., 23786.3, 34641.8, 71520.7, 73606.9, 78383.3,
97387.9, 144313.4, 4607.6, 19275.1, 152894.2, 44240.1],
units='ms', t_stop=160000 * pq.ms)
sttc_unsorted_E7_E3 = sc.sttc(spiketrain_E7,
spiketrain_E3, dt=0.10 * pq.s)
self.assertAlmostEqual(sttc_unsorted_E7_E3, 1)
spiketrain_E7.sort()
spiketrain_E3.sort()
sttc_sorted_E7_E3 = sc.sttc(spiketrain_E7,
spiketrain_E3, dt=0.10 * pq.s)
self.assertAlmostEqual(sttc_unsorted_E7_E3, sttc_sorted_E7_E3)

spiketrain_E8 = neo.SpikeTrain(
[20646.8, 25875.1, 26154.4, 35121., 55909.7, 79164.8,
110849.8, 117484.1, 3731.5, 4213.9, 119995.1, 123748.1,
171016.8, 172989., 185145.2, 12043.5, 185995.9, 186740.1,
12629.8, 23394.3, 34993.2], units='ms', t_stop=210000 * pq.ms)

spiketrain_B3 = neo.SpikeTrain(
[10600.7, 19699.6, 22803., 40769.3, 121385.7, 127402.9,
130829.2, 134363.8, 1193.5, 8012.7, 142037.3, 146628.2,
165925.3, 168489.3, 175194.3, 10339.8, 178676.4, 180807.2,
201431.3, 22231.1, 38113.4], units='ms', t_stop=210000 * pq.ms)

self.assertTrue(
sc.sttc(spiketrain_E8, spiketrain_B3, dt=0.10 * pq.s) < 1)

sttc_unsorted_E8_B3 = sc.sttc(spiketrain_E8,
spiketrain_B3, dt=0.10 * pq.s)
spiketrain_E8.sort()
spiketrain_B3.sort()
sttc_sorted_E8_B3 = sc.sttc(spiketrain_E8,
spiketrain_B3, dt=0.10 * pq.s)
self.assertAlmostEqual(sttc_unsorted_E8_B3, sttc_sorted_E8_B3)

def test_exist_alias(self):
# Test if alias cch still exists.
self.assertEqual(sc.spike_time_tiling_coefficient, sc.sttc)
Expand Down

0 comments on commit a988016

Please sign in to comment.