Skip to content

Commit 9d77075

Browse files
author
Benjamin Moody
committed
Record.__eq__: replace exact type comparisons with isinstance.
When comparing the attributes of two records, if a value is an instance of a class derived from 'np.ndarray' or a class derived from 'list', it should be treated the same way as an 'np.ndarray' or a 'list'. Note that there currently are no such classes defined or used by this package. Note also that in any case, the respective types of the two attributes must be equal in order for the values to be considered equal.
1 parent 68bb86d commit 9d77075

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

wfdb/io/record.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -625,11 +625,11 @@ def __eq__(self, other, verbose=False):
625625
print('Mismatch in attribute: %s' % k, v1, v2)
626626
return False
627627

628-
if type(v1) == np.ndarray:
628+
if isinstance(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)):
631+
elif (isinstance(v1, list) and len(v1) == len(v2)
632+
and all(isinstance(e, np.ndarray) for e in v1)):
633633
for (e1, e2) in zip(v1, v2):
634634
np.testing.assert_array_equal(e1, e2)
635635
else:

0 commit comments

Comments
 (0)