Skip to content

Commit

Permalink
Merge pull request #3002 from h-mayorquin/eliminate_unecessary_inheri…
Browse files Browse the repository at this point in the history
…tance_select_channels

Avoid redirection to not implemented method in `BaseRecording.select_channels`
  • Loading branch information
alejoe91 authored Jun 10, 2024
2 parents a016998 + 819e2f6 commit 530332d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/spikeinterface/core/baserecording.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def _extra_metadata_to_folder(self, folder):
if time_vector is not None:
np.save(folder / f"times_cached_seg{segment_index}.npy", time_vector)

def _select_channels(self, channel_ids: list | np.array | tuple) -> "BaseRecording":
def select_channels(self, channel_ids: list | np.array | tuple) -> "BaseRecording":
"""
Returns a new recording object with a subset of channels.
Expand Down
5 changes: 1 addition & 4 deletions src/spikeinterface/core/baserecordingsnippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ def is_filtered(self):
# the is_filtered is handle with annotation
return self._annotations.get("is_filtered", False)

def _select_channels(self, channel_ids: list | np.array | tuple) -> "BaseRecordingSnippets":
raise NotImplementedError

def _channel_slice(self, channel_ids, renamed_channel_ids=None):
raise NotImplementedError

Expand Down Expand Up @@ -478,7 +475,7 @@ def select_channels(self, channel_ids):
BaseRecordingSnippets
The object with sliced channels
"""
return self._select_channels(channel_ids)
raise NotImplementedError

def remove_channels(self, remove_channel_ids):
"""
Expand Down
3 changes: 2 additions & 1 deletion src/spikeinterface/core/basesnippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,14 @@ def get_snippets_from_frames(
def _save(self, format="binary", **save_kwargs):
raise NotImplementedError

def _select_channels(self, channel_ids: list | np.array | tuple) -> "BaseSnippets":
def select_channels(self, channel_ids: list | np.array | tuple) -> "BaseSnippets":
from .channelslice import ChannelSliceSnippets

return ChannelSliceSnippets(self, channel_ids)

def _channel_slice(self, channel_ids, renamed_channel_ids=None):
from .channelslice import ChannelSliceSnippets
import warnings

warnings.warn(
"Snippets.channel_slice will be removed in version 0.103, use `select_channels` or `rename_channels` instead.",
Expand Down

0 comments on commit 530332d

Please sign in to comment.