From 97f110796be00cbe75f02fc3c04823cb218fdafb Mon Sep 17 00:00:00 2001 From: Tom Pollard Date: Wed, 9 Oct 2024 15:38:55 -0400 Subject: [PATCH] cast filebytes to int64 NPY_PROMOTION_STATE=weak_and_warn reports that several variables changed from int64 to uint8. Casting to int64 addresses the issue. --- wfdb/io/annotation.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/wfdb/io/annotation.py b/wfdb/io/annotation.py index b398fa07..506df65f 100644 --- a/wfdb/io/annotation.py +++ b/wfdb/io/annotation.py @@ -2134,6 +2134,7 @@ def proc_ann_bytes(filebytes, sampto): """ # Base annotation fields sample, label_store, subtype, chan, num, aux_note = [], [], [], [], [], [] + filebytes = filebytes.astype(np.int64) # Indexing Variables @@ -2216,16 +2217,17 @@ def proc_core_fields(filebytes, bpi): """ sample_diff = 0 + filebytes = filebytes.astype(np.int64) # The current byte pair will contain either the actual d_sample + annotation store value, # or 0 + SKIP. while filebytes[bpi, 1] >> 2 == 59: # 4 bytes storing dt skip_diff = ( - (int(filebytes[bpi + 1, 0]) << 16) - + (int(filebytes[bpi + 1, 1]) << 24) - + (int(filebytes[bpi + 2, 0]) << 0) - + (int(filebytes[bpi + 2, 1]) << 8) + (filebytes[bpi + 1, 0] << 16) + + (filebytes[bpi + 1, 1] << 24) + + (filebytes[bpi + 2, 0] << 0) + + (filebytes[bpi + 2, 1] << 8) ) # Data type is long integer (stored in two's complement). Range -2**31 to 2**31 - 1 @@ -2237,7 +2239,9 @@ def proc_core_fields(filebytes, bpi): # Not a skip - it is the actual sample number + annotation type store value label_store = filebytes[bpi, 1] >> 2 - sample_diff += int(filebytes[bpi, 0] + 256 * (filebytes[bpi, 1] & 3)) + sample_diff += np.int64(filebytes[bpi, 0]) + 256 * np.int64( + filebytes[bpi, 1] & 3 + ) bpi = bpi + 1 return sample_diff, label_store, bpi