diff options
Diffstat (limited to 'test/test_distance.py')
-rw-r--r-- | test/test_distance.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test_distance.py b/test/test_distance.py index 93053e7..17ca14a 100644 --- a/test/test_distance.py +++ b/test/test_distance.py @@ -61,6 +61,25 @@ def test_spike(): assert_array_almost_equal(f.y1, expected_y1, decimal=14) assert_array_almost_equal(f.y2, expected_y2, decimal=14) + # check with some equal spike times + t1 = np.array([0.2,0.4,0.6]) + t2 = np.array([0.1,0.4,0.5,0.6]) + + expected_times = [0.0,0.1,0.2,0.4,0.5,0.6,1.0] + s1 = np.array([0.0, 0.1*0.1/0.2, 0.1, 0.0, 0.0, 0.0, 0.0]) + s2 = np.array([0.0, 0.1, 0.1*0.2/0.3, 0.0, 0.1, 0.0, 0.0]) + isi1 = np.array([0.2, 0.2, 0.2, 0.2, 0.2, 0.4]) + isi2 = np.array([0.1, 0.3, 0.3, 0.1, 0.1, 0.4]) + expected_y1 = (s1[:-1]*isi2+s2[:-1]*isi1) / (0.5*(isi1+isi2)**2) + expected_y2 = (s1[1:]*isi2+s2[1:]*isi1) / (0.5*(isi1+isi2)**2) + + f = spk.spike_distance(t1, t2, 1.0) + + assert_equal(f.x, expected_times) + assert_array_almost_equal(f.y1, expected_y1, decimal=14) + assert_array_almost_equal(f.y2, expected_y2, decimal=14) + + if __name__ == "main": test_isi() test_spike() |