Skip to content

Commit d86a79b

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 d86a79b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

wfdb/io/convert/edf.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,23 +402,26 @@ 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) / adc_gain_all[i]
415418
else:
416419
for j in range(sig_len):
417420
start_ind = j * samps_per_frame[i]
418421
stop_ind = start_ind + samps_per_frame[i]
419422
sig_data[j, i] = np.mean(
420423
(temp_sig_data[start_ind:stop_ind] - baseline[i])
421-
/ adc_gain_all[i]
424+
.astype(np.int64) / adc_gain_all[i]
422425
)
423426

424427
# This is the closest I can get to the original implementation

0 commit comments

Comments
 (0)