Skip to content

Commit 44adc55

Browse files
committed
bette error message and docstring to test
1 parent 1fb6ee3 commit 44adc55

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/spikeinterface/core/channelslice.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ def __init__(self, parent_recording, channel_ids=None, renamed_channel_ids=None)
3131
parents_chan_ids = parent_recording.get_channel_ids()
3232

3333
# some checks
34-
is_channel_in_parent = [chan_id in parents_chan_ids.tolist() for chan_id in self._channel_ids.tolist()]
35-
assert all(is_channel_in_parent), "ChannelSliceRecording : channel ids are not all in parents"
34+
# We use lists to compare numpy scalar types as their python versions (e.g. int vs int64())
35+
channel_ids_not_in_parents = [id for id in self._channel_ids.tolist() if id not in parents_chan_ids.tolist()]
36+
assert (
37+
len(channel_ids_not_in_parents) == 0
38+
), f"ChannelSliceRecording : channel ids {channel_ids_not_in_parents} are not all in parent ids {parents_chan_ids}"
3639

3740
assert len(self._channel_ids) == len(
3841
self._renamed_channel_ids
@@ -42,6 +45,7 @@ def __init__(self, parent_recording, channel_ids=None, renamed_channel_ids=None)
4245
), "ChannelSliceRecording : channel_ids are not unique"
4346

4447
sampling_frequency = parent_recording.get_sampling_frequency()
48+
assert sampling_frequency > 0, "Sampling frequency must be positive."
4549

4650
BaseRecording.__init__(
4751
self,

src/spikeinterface/core/tests/test_channelsaggregationrecording.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ def test_channel_aggregation_does_not_preserve_ids_not_the_same_type():
119119

120120

121121
def test_channel_aggregation_with_string_dtypes_of_different_size():
122+
"""
123+
Fixes issue https://github.com/SpikeInterface/spikeinterface/issues/3733
124+
125+
This tests that the channel ids are propagated in the aggregation even if they are strings of different
126+
string dtype sizes.
127+
"""
122128
recording1 = generate_recording(num_channels=2, durations=[10], set_probe=False)
123129
recording1 = recording1.rename_channels(new_channel_ids=np.array(["8", "9"], dtype="<U1"))
124130

0 commit comments

Comments
 (0)