Skip to content

Commit

Permalink
Fix small bug in brainbox acorr(). Closes int-brain-lab#152
Browse files Browse the repository at this point in the history
  • Loading branch information
rossant committed Sep 14, 2020
1 parent c55968e commit a9d2bbf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion brainbox/singlecell/singlecell.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def acorr(spike_times, bin_size=None, window_size=None):
Returns an `(winsize_samples,)` array with the auto-correlogram.
"""
xc = xcorr(spike_times, np.zeros_like(spike_times), bin_size=bin_size, window_size=window_size)
xc = xcorr(spike_times, np.zeros_like(spike_times, dtype=np.int32),
bin_size=bin_size, window_size=window_size)
return xc[0, 0, :]


Expand Down
12 changes: 12 additions & 0 deletions brainbox/tests/test_singlecell.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ def test_acorr_0(self):

self.assertTrue(np.allclose(c, c_expected))

def test_acorr_1(self):
spike_times = np.array([0, 10, 10, 20], dtype=np.float64)
bin_size = 1
winsize_bins = 2 * 3 + 1

c_expected = np.zeros(7, dtype=np.float64)
c_expected[3] = 1

c = acorr(spike_times, bin_size=bin_size, window_size=winsize_bins)

self.assertTrue(np.allclose(c, c_expected))


class TestPeths(unittest.TestCase):
def test_peths_synthetic(self):
Expand Down

0 comments on commit a9d2bbf

Please sign in to comment.