Skip to content

Commit b09bab4

Browse files
author
Benjamin Moody
committed
SignalMixin.smooth_frames: check lengths of input arrays.
Ensure that all of the input signals have the expected lengths before trying to do anything else. (If any of the signal lengths were wrong, this would typically have raised a ValueError later on - though not always, since numpy will try to be clever if one of the arguments is an array of length 1.)
1 parent 13a8948 commit b09bab4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

wfdb/io/_signal.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,12 @@ def smooth_frames(self, sigtype='physical'):
841841

842842
n_sig = len(expanded_signal)
843843
sig_len = int(len(expanded_signal[0])/spf[0])
844+
for ch in range(n_sig):
845+
if len(expanded_signal[ch]) != sig_len * spf[ch]:
846+
raise ValueError("length mismatch: signal %d has %d samples,"
847+
" expected %dx%d"
848+
% (ch, len(expanded_signal),
849+
sig_len, spf[ch]))
844850
signal = np.zeros((sig_len, n_sig), dtype=output_dtype)
845851

846852
for ch in range(n_sig):

0 commit comments

Comments
 (0)