Skip to content

Commit

Permalink
cast filebytes to int/int64
Browse files Browse the repository at this point in the history
NPY_PROMOTION_STATE=weak_and_warn reports that several variables changed from int64 to uint8.
  • Loading branch information
tompollard committed Oct 9, 2024
1 parent 56b7d5c commit 0636c75
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions wfdb/io/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2219,7 +2219,7 @@ def proc_core_fields(filebytes, bpi):

# The current byte pair will contain either the actual d_sample + annotation store value,
# or 0 + SKIP.
while filebytes[bpi, 1] >> 2 == 59:
while int(filebytes[bpi, 1]) >> 2 == 59:
# 4 bytes storing dt
skip_diff = (
(int(filebytes[bpi + 1, 0]) << 16)
Expand All @@ -2237,7 +2237,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
Expand Down

0 comments on commit 0636c75

Please sign in to comment.