Skip to content

Commit 7008e47

Browse files
author
Benjamin Moody
committed
Record.__eq__: allow checking equality of lists of arrays.
The Record.__eq__ function is currently used in the test suite to check whether two Record objects have the same contents. (This function doesn't actually conform to the standard Python API, but it works for this purpose.) In the case of "expanded"-format records, the e_p_signal and/or e_d_signal attributes are lists of numpy.ndarray objects, not numpy.ndarray objects themselves. In order to compare these for equality we must compare each element separately.
1 parent d0173b4 commit 7008e47

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

wfdb/io/record.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,10 @@ def __eq__(self, other, verbose=False):
628628
if type(v1) == np.ndarray:
629629
# Necessary for nans
630630
np.testing.assert_array_equal(v1, v2)
631+
elif (type(v1) == list and len(v1) == len(v2)
632+
and all(type(e) == np.ndarray for e in v1)):
633+
for (e1, e2) in zip(v1, v2):
634+
np.testing.assert_array_equal(e1, e2)
631635
else:
632636
if v1 != v2:
633637
if verbose:

0 commit comments

Comments
 (0)