Skip to content

Commit 522b8d7

Browse files
committed
add test
1 parent 531f6ed commit 522b8d7

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/spikesorting/test_utils.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from uuid import UUID
22

3+
import numpy as np
34
import pytest
45

56

@@ -25,3 +26,42 @@ def test_get_merge_ids(pop_spike_merge, mini_dict):
2526
assert (
2627
ret[0] == pop_spike_merge["merge_id"]
2728
), "Unexpected merge_id from util"
29+
30+
31+
def test_fetch_data(
32+
spike_v1_group,
33+
pop_spikes_group,
34+
):
35+
spike_times = spike_v1_group.SortedSpikesGroup().fetch_spike_data(
36+
pop_spikes_group, return_unit_ids=False
37+
)
38+
39+
flat_spikes = np.concatenate(spike_times)
40+
start = np.min(flat_spikes)
41+
rng = (start, start + 10)
42+
43+
spikes_tuple = spike_v1_group.SortedSpikesGroup().fetch_spike_data(
44+
pop_spikes_group, time_slice=rng
45+
)
46+
spikes_slice = spike_v1_group.SortedSpikesGroup().fetch_spike_data(
47+
pop_spikes_group, time_slice=slice(*rng)
48+
)
49+
spikes_list = spike_v1_group.SortedSpikesGroup().fetch_spike_data(
50+
pop_spikes_group, time_slice=list(rng)
51+
)
52+
53+
flat_tuple = np.concatenate(spikes_tuple)
54+
flat_slice = np.concatenate(spikes_slice)
55+
flat_list = np.concatenate(spikes_list)
56+
57+
assert all(
58+
[
59+
np.allclose(flat_tuple, flat_slice),
60+
np.allclose(flat_tuple, flat_list),
61+
np.allclose(flat_slice, flat_list),
62+
]
63+
), "Inconsistent spike data slices"
64+
65+
assert all(flat_tuple >= rng[0]) and all(
66+
flat_tuple <= rng[1]
67+
), "Out of range"

0 commit comments

Comments
 (0)