Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change in type promotion. Fixes to annotation.py #506

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions wfdb/io/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2162,7 +2162,7 @@ def proc_ann_bytes(filebytes, sampto):
update = {"subtype": True, "chan": True, "num": True, "aux_note": True}
# Get the next label store value - it may indicate additional
# fields for this annotation, or the values of the next annotation.
current_label_store = filebytes[bpi, 1] >> 2
current_label_store = int(filebytes[bpi, 1]) >> 2

while current_label_store > 59:
subtype, chan, num, aux_note, update, bpi = proc_extra_field(
Expand All @@ -2176,7 +2176,7 @@ def proc_ann_bytes(filebytes, sampto):
update,
)

current_label_store = filebytes[bpi, 1] >> 2
current_label_store = int(filebytes[bpi, 1]) >> 2

# Set defaults or carry over previous values if necessary
subtype, chan, num, aux_note = update_extra_fields(
Expand Down 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 @@ -2236,8 +2236,10 @@ def proc_core_fields(filebytes, bpi):
bpi = bpi + 3

# 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))
label_store = int(filebytes[bpi, 1]) >> 2
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 Expand Up @@ -2322,7 +2324,7 @@ def proc_extra_field(
aux_notebytes = filebytes[
bpi + 1 : bpi + 1 + int(np.ceil(aux_notelen / 2.0)), :
].flatten()
if aux_notelen & 1:
if int(aux_notelen) & 1:
aux_notebytes = aux_notebytes[:-1]
# The aux_note string
aux_note.append("".join([chr(char) for char in aux_notebytes]))
Expand Down
Loading