11from __future__ import annotations
22from copy import deepcopy
3- from typing import Literal , Tuple
3+ from typing import Literal
44import warnings
55from pathlib import Path
66import os
@@ -930,8 +930,8 @@ def get_rec_attributes(recording):
930930
931931
932932def 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
0 commit comments