From 42e3740977b41b275f478a59c227fd06747b9707 Mon Sep 17 00:00:00 2001 From: Tom Pollard Date: Wed, 9 Oct 2024 17:17:49 -0400 Subject: [PATCH] explicit type casting NPY_PROMOTION_STATE=weak_and_warn reports that several variables changed from int16 to int64. Casting to int64 addresses the issue. --- wfdb/io/convert/edf.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/wfdb/io/convert/edf.py b/wfdb/io/convert/edf.py index e3096884..c64f24d9 100644 --- a/wfdb/io/convert/edf.py +++ b/wfdb/io/convert/edf.py @@ -402,22 +402,28 @@ def read_edf( temp_sig_data = np.fromfile(edf_file, dtype=np.int16) temp_sig_data = temp_sig_data.reshape((-1, sum(samps_per_block))) temp_all_sigs = np.hsplit(temp_sig_data, np.cumsum(samps_per_block)[:-1]) + for i in range(n_sig): # Check if `samps_per_frame` has all equal values if samps_per_frame.count(samps_per_frame[0]) == len(samps_per_frame): sig_data[:, i] = ( - temp_all_sigs[i].flatten() - baseline[i] + (temp_all_sigs[i].flatten() - baseline[i]).astype(np.int64) ) / adc_gain_all[i] else: temp_sig_data = temp_all_sigs[i].flatten() + if samps_per_frame[i] == 1: - sig_data[:, i] = (temp_sig_data - baseline[i]) / adc_gain_all[i] + sig_data[:, i] = (temp_sig_data - baseline[i]).astype( + np.int64 + ) / adc_gain_all[i] else: for j in range(sig_len): start_ind = j * samps_per_frame[i] stop_ind = start_ind + samps_per_frame[i] sig_data[j, i] = np.mean( - (temp_sig_data[start_ind:stop_ind] - baseline[i]) + ( + temp_sig_data[start_ind:stop_ind] - baseline[i] + ).astype(np.int64) / adc_gain_all[i] )