From e8431dc35022a0124653c4e80a4e14160d88ba73 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Thu, 23 Nov 2023 16:09:39 +0100 Subject: [PATCH] Assert renamed_channels/unit_ids is unique --- src/spikeinterface/core/channelslice.py | 4 ++++ src/spikeinterface/core/unitsselectionsorting.py | 1 + 2 files changed, 5 insertions(+) diff --git a/src/spikeinterface/core/channelslice.py b/src/spikeinterface/core/channelslice.py index 9987edadc6..718f27f688 100644 --- a/src/spikeinterface/core/channelslice.py +++ b/src/spikeinterface/core/channelslice.py @@ -20,6 +20,10 @@ def __init__(self, parent_recording, channel_ids=None, renamed_channel_ids=None) channel_ids = parent_recording.get_channel_ids() if renamed_channel_ids is None: renamed_channel_ids = channel_ids + else: + assert len(renamed_channel_ids) == len( + np.unique(renamed_channel_ids) + ), "renamed_channel_ids must be unique!" self._parent_recording = parent_recording self._channel_ids = np.asarray(channel_ids) diff --git a/src/spikeinterface/core/unitsselectionsorting.py b/src/spikeinterface/core/unitsselectionsorting.py index 38916e5bf1..379575cbfa 100644 --- a/src/spikeinterface/core/unitsselectionsorting.py +++ b/src/spikeinterface/core/unitsselectionsorting.py @@ -18,6 +18,7 @@ def __init__(self, parent_sorting, unit_ids=None, renamed_unit_ids=None): unit_ids = parent_sorting.get_unit_ids() if renamed_unit_ids is None: renamed_unit_ids = unit_ids + assert len(renamed_unit_ids) == len(np.unique(renamed_unit_ids)), "renamed_unit_ids must be unique!" self._parent_sorting = parent_sorting self._unit_ids = np.asarray(unit_ids)