Skip to content

Commit 945fc15

Browse files
committed
Suggestions from code review
1 parent bc1c704 commit 945fc15

4 files changed

Lines changed: 7 additions & 39 deletions

File tree

src/spikeinterface/core/recording_tools.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22
from copy import deepcopy
3-
from typing import Literal, Tuple
3+
from typing import Literal
44
import warnings
55
from pathlib import Path
66
import os
@@ -930,8 +930,8 @@ def get_rec_attributes(recording):
930930

931931

932932
def do_recording_attributes_match(
933-
recording1: "BaseRecording", recording2_attributes: bool, check_is_filtered: bool = True, check_dtype: bool = True
934-
) -> Tuple[bool, str]:
933+
recording1: "BaseRecording", recording2_attributes: bool, check_dtype: bool = True
934+
) -> tuple[bool, str]:
935935
"""
936936
Check if two recordings have the same attributes
937937
@@ -941,8 +941,6 @@ def do_recording_attributes_match(
941941
The first recording object
942942
recording2_attributes : dict
943943
The recording attributes to test against
944-
check_is_filtered : bool, default: True
945-
If True, check if the recordings are filtered
946944
check_dtype : bool, default: True
947945
If True, check if the recordings have the same dtype
948946
@@ -962,31 +960,24 @@ def do_recording_attributes_match(
962960
non_matching_attrs = []
963961

964962
if not np.array_equal(recording1_attributes["channel_ids"], recording2_attributes["channel_ids"]):
965-
attributes_match = False
966963
non_matching_attrs.append("channel_ids")
967964
if not recording1_attributes["sampling_frequency"] == recording2_attributes["sampling_frequency"]:
968-
attributes_match = False
969965
non_matching_attrs.append("sampling_frequency")
970966
if not recording1_attributes["num_channels"] == recording2_attributes["num_channels"]:
971-
attributes_match = False
972967
non_matching_attrs.append("num_channels")
973968
if not recording1_attributes["num_samples"] == recording2_attributes["num_samples"]:
974-
attributes_match = False
975969
non_matching_attrs.append("num_samples")
976-
if check_is_filtered:
977-
if not recording1_attributes["is_filtered"] == recording2_attributes["is_filtered"]:
978-
attributes_match = False
979-
non_matching_attrs.append("is_filtered")
980970
# dtype is optional
981971
if "dtype" in recording1_attributes and "dtype" in recording2_attributes:
982972
if check_dtype:
983973
if not recording1_attributes["dtype"] == recording2_attributes["dtype"]:
984-
attributes_match = False
985974
non_matching_attrs.append("dtype")
986975

987976
if len(non_matching_attrs) > 0:
977+
attributes_match = False
988978
exception_str = f"Recordings do not match in the following attributes: {non_matching_attrs}"
989979
else:
980+
attributes_match = True
990981
exception_str = ""
991982

992983
return attributes_match, exception_str

src/spikeinterface/core/sortinganalyzer.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,7 @@ def load_from_zarr(cls, folder, recording=None):
608608

609609
return sorting_analyzer
610610

611-
def set_temporary_recording(
612-
self, recording: BaseRecording, check_is_filtered: bool = True, check_dtype: bool = True
613-
):
611+
def set_temporary_recording(self, recording: BaseRecording, check_dtype: bool = True):
614612
"""
615613
Sets a temporary recording object. This function can be useful to temporarily set
616614
a "cached" recording object that is not saved in the SortingAnalyzer object to speed up
@@ -622,14 +620,12 @@ def set_temporary_recording(
622620
----------
623621
recording : BaseRecording
624622
The recording object to set as temporary recording.
625-
check_is_filtered : bool, default: True
626-
If True, check that the temporary recording is filtered in the same way as the original recording.
627623
check_dtype : bool, default: True
628624
If True, check that the dtype of the temporary recording is the same as the original recording.
629625
"""
630626
# check that recording is compatible
631627
attributes_match, exception_str = do_recording_attributes_match(
632-
recording, self.rec_attributes, check_is_filtered=check_is_filtered, check_dtype=check_dtype
628+
recording, self.rec_attributes, check_dtype=check_dtype
633629
)
634630
if not attributes_match:
635631
raise ValueError(exception_str)

src/spikeinterface/core/tests/test_recording_tools.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -316,16 +316,6 @@ def test_do_recording_attributes_match():
316316
assert not do_match
317317
assert "sampling_frequency" in exc
318318

319-
# check is_filtered options
320-
rec_attributes = get_rec_attributes(recording)
321-
rec_attributes["is_filtered"] = not rec_attributes["is_filtered"]
322-
323-
do_match, exc = do_recording_attributes_match(recording, rec_attributes)
324-
assert not do_match
325-
assert "is_filtered" in exc
326-
do_match, exc = do_recording_attributes_match(recording, rec_attributes, check_is_filtered=False)
327-
assert do_match
328-
329319
# check dtype options
330320
rec_attributes = get_rec_attributes(recording)
331321
rec_attributes["dtype"] = "int16"

src/spikeinterface/core/tests/test_sortinganalyzer.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,6 @@ def test_SortingAnalyzer_tmp_recording(dataset):
144144
with pytest.raises(ValueError):
145145
sorting_analyzer.set_temporary_recording(recording_sliced)
146146

147-
# test with different is_filtered
148-
recording_filt = recording.clone()
149-
recording_filt.annotate(is_filtered=False)
150-
with pytest.raises(ValueError):
151-
sorting_analyzer.set_temporary_recording(recording_filt)
152-
153-
# thest with additional check_is_filtered
154-
sorting_analyzer.set_temporary_recording(recording_filt, check_is_filtered=False)
155-
156147

157148
def _check_sorting_analyzers(sorting_analyzer, original_sorting, cache_folder):
158149

0 commit comments

Comments
 (0)