Skip to content

Commit 7ae21d4

Browse files
author
Benjamin Moody
committed
adc (inplace=True, expanded=True): refactor for clarity.
1 parent d629897 commit 7ae21d4

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

wfdb/io/_signal.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -551,23 +551,14 @@ def adc_inplace_2d(p_signal):
551551
if inplace:
552552
if expanded:
553553
for ch in range(self.n_sig):
554-
# NAN locations for the channel
555-
ch_nanlocs = np.isnan(self.e_p_signal[ch])
556-
np.multiply(
557-
self.e_p_signal[ch],
558-
self.adc_gain[ch],
559-
self.e_p_signal[ch],
560-
)
561-
np.add(
562-
self.e_p_signal[ch],
563-
self.baseline[ch],
564-
self.e_p_signal[ch],
565-
)
566-
np.round(self.e_p_signal[ch], 0, self.e_p_signal[ch])
567-
self.e_p_signal[ch] = self.e_p_signal[ch].astype(
568-
intdtype, copy=False
569-
)
570-
self.e_p_signal[ch][ch_nanlocs] = d_nans[ch]
554+
ch_p_signal = self.e_p_signal[ch]
555+
ch_nanlocs = np.isnan(ch_p_signal)
556+
np.multiply(ch_p_signal, self.adc_gain[ch], ch_p_signal)
557+
np.add(ch_p_signal, self.baseline[ch], ch_p_signal)
558+
np.round(ch_p_signal, 0, ch_p_signal)
559+
ch_d_signal = ch_p_signal.astype(intdtype, copy=False)
560+
ch_d_signal[ch_nanlocs] = d_nans[ch]
561+
self.e_p_signal[ch] = ch_d_signal
571562
self.e_d_signal = self.e_p_signal
572563
self.e_p_signal = None
573564
else:

0 commit comments

Comments
 (0)