@@ -27,6 +27,17 @@ def __hash__(self):
2727 return (f'{ self .sampFreqUsed } ;{ self .microsPerSampUsed } ;'
2828 f'{ [s .__hash__ () for s in self .sects ]} ' ).__hash__ ()
2929
30+ def is_equivalent (self , other , rel_tol = 0 , abs_tol = 0 ):
31+ if len (self .sects ) != len (other .sects ):
32+ return False
33+ else :
34+ # do not check for gaps if only a single section is present
35+ for sec_id in range (len (self .sects )- 1 ):
36+ if not self .sects [sec_id ].is_equivalent (
37+ other .sects [sec_id ], rel_tol = rel_tol , abs_tol = abs_tol ):
38+ return False
39+ return True
40+
3041
3142class NcsSection :
3243 """
@@ -66,6 +77,12 @@ def __hash__(self):
6677 s = f'{ self .startRec } ;{ self .startTime } ;{ self .endRec } ;{ self .endTime } ;{ self .n_samples } '
6778 return s .__hash__ ()
6879
80+ def is_equivalent (self , other , rel_tol = 0 , abs_tol = 0 ):
81+ eq_start = math .isclose (self .startTime , other .startTime , rel_tol = rel_tol , abs_tol = abs_tol )
82+ eq_end = math .isclose (self .endTime , other .endTime , rel_tol = rel_tol , abs_tol = abs_tol )
83+ return eq_start & eq_end
84+
85+
6986 def before_time (self , rhb ):
7087 """
7188 Determine if this section is completely before another section in time.
0 commit comments