Skip to content

Commit 42e3740

Browse files
committed
explicit type casting
NPY_PROMOTION_STATE=weak_and_warn reports that several variables changed from int16 to int64. Casting to int64 addresses the issue.
1 parent 56b7d5c commit 42e3740

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

wfdb/io/convert/edf.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,22 +402,28 @@ def read_edf(
402402
temp_sig_data = np.fromfile(edf_file, dtype=np.int16)
403403
temp_sig_data = temp_sig_data.reshape((-1, sum(samps_per_block)))
404404
temp_all_sigs = np.hsplit(temp_sig_data, np.cumsum(samps_per_block)[:-1])
405+
405406
for i in range(n_sig):
406407
# Check if `samps_per_frame` has all equal values
407408
if samps_per_frame.count(samps_per_frame[0]) == len(samps_per_frame):
408409
sig_data[:, i] = (
409-
temp_all_sigs[i].flatten() - baseline[i]
410+
(temp_all_sigs[i].flatten() - baseline[i]).astype(np.int64)
410411
) / adc_gain_all[i]
411412
else:
412413
temp_sig_data = temp_all_sigs[i].flatten()
414+
413415
if samps_per_frame[i] == 1:
414-
sig_data[:, i] = (temp_sig_data - baseline[i]) / adc_gain_all[i]
416+
sig_data[:, i] = (temp_sig_data - baseline[i]).astype(
417+
np.int64
418+
) / adc_gain_all[i]
415419
else:
416420
for j in range(sig_len):
417421
start_ind = j * samps_per_frame[i]
418422
stop_ind = start_ind + samps_per_frame[i]
419423
sig_data[j, i] = np.mean(
420-
(temp_sig_data[start_ind:stop_ind] - baseline[i])
424+
(
425+
temp_sig_data[start_ind:stop_ind] - baseline[i]
426+
).astype(np.int64)
421427
/ adc_gain_all[i]
422428
)
423429

0 commit comments

Comments
 (0)