From 2541c7033c4e88230dde9350723422e70ade01b2 Mon Sep 17 00:00:00 2001 From: Tom Pollard Date: Wed, 9 Oct 2024 15:22:07 -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 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wfdb/io/annotation.py b/wfdb/io/annotation.py index b398fa07..0daa48e0 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,7 @@ 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