Skip to content

Commit 19c1eb3

Browse files
author
Benjamin Moody
committed
convert_dtype: don't change p_signal when smooth_frames is false.
If physical is true, and smooth_frames is false, and e_p_signal is None, this function should raise an exception. It should not silently modify p_signal instead. The previous code didn't make any sense: p_signal is a numpy array, so you can't change its data type by assigning to a slice of it, and even if that conversion were possible, the slicing was being done along the wrong axis. This reverts a dubious change in commit 725e7a6, which seems unrelated to the rest of that commit.
1 parent 0d41603 commit 19c1eb3

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

wfdb/io/_signal.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -705,14 +705,9 @@ def convert_dtype(self, physical, return_res, smooth_frames):
705705
if current_dtype != return_dtype:
706706
self.p_signal = self.p_signal.astype(return_dtype, copy=False)
707707
else:
708-
if self.e_p_signal is not None:
709-
for ch in range(self.n_sig):
710-
if self.e_p_signal[ch].dtype != return_dtype:
711-
self.e_p_signal[ch] = self.e_p_signal[ch].astype(return_dtype, copy=False)
712-
else:
713-
for ch in range(self.n_sig):
714-
if self.p_signal[ch].dtype != return_dtype:
715-
self.p_signal[ch] = self.p_signal[ch].astype(return_dtype, copy=False)
708+
for ch in range(self.n_sig):
709+
if self.e_p_signal[ch].dtype != return_dtype:
710+
self.e_p_signal[ch] = self.e_p_signal[ch].astype(return_dtype, copy=False)
716711
else:
717712
return_dtype = 'int'+str(return_res)
718713
if smooth_frames:

0 commit comments

Comments
 (0)