OverflowError: Python integer 256 out of bounds for uint8
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 48/100
Research direction
Start in wfdb/io/annotation.py at proc_core_fields, using the traceback and the reported demo4.py invocation to reproduce the OverflowError. Compare the separate script's rdann result with the notebook behavior; done means demo4.py runs successfully on the sample data without the uint8 overflow.
Written by the indexing model from the issue text.
Description
I am breaking the demos in the notebook in individual scripts to get acquainted with the package to learn how it works and adapt it to my needs.
Running demo4 as a separate script with python I get this error traceback:
D:\Users\xxx\Work\__WFDB\wfdb-python>python demo4.py
Traceback (most recent call last):
File "D:\Users\xxx\Work\__WFDB\wfdb-python\demo4.py", line 12, in <module>
annotation = wfdb.rdann('sample-data/100', 'atr', sampfrom=100000, sampto=110000)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Users\xxx\Work\__WFDB\wfdb-python\wfdb\io\annotation.py", line 1953, in rdann
(sample, label_store, subtype, chan, num, aux_note) = proc_ann_bytes(
^^^^^^^^^^^^^^^
File "D:\Users\xxx\Work\__WFDB\wfdb-python\wfdb\io\annotation.py", line 2154, in proc_ann_bytes
sample_diff, current_label_store, bpi = proc_core_fields(filebytes, bpi)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Users\xxx\Work\__WFDB\wfdb-python\wfdb\io\annotation.py", line 2240, in proc_core_fields
sample_diff += int(filebytes[bpi, 0] + 256 * (filebytes[bpi, 1] & 3))
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
OverflowError: Python integer 256 out of bounds for uint8
The same happens with Linux (Ubuntu 22.04).
After changing the highlighted line it works like the notebook.
$ git diff
diff --git a/wfdb/io/annotation.py b/wfdb/io/annotation.py
index b398fa0..4d451b1 100644
--- a/wfdb/io/annotation.py
+++ b/wfdb/io/annotation.py
@@ -2237,7 +2237,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 += int(filebytes[bpi, 0]) + 256 * int(filebytes[bpi, 1] & 3)
bpi = bpi + 1
return sample_diff, label_store, bpi
EDIT:
Python versions
Windows: 3.12.4
Linux: 3.10.12
- Dominant language
- Jupyter Notebook
- Stars
- 853
- Forks
- 322
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MIT-LCP/wfdb-python
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
MIT-LCP/wfdb-python#568 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
MIT-LCP/wfdb-python#557 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 58/100
MIT-LCP/wfdb-python#554 ·
-
WFDB path ignored Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
MIT-LCP/wfdb-python#545 ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
MIT-LCP/wfdb-python#540 ·
All issues in MIT-LCP/wfdb-python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
TauricResearch/TradingAgents#1397 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
TencentCloud/Octop#1085 · 1 comment ·
-
Sandy macrofaunal assemblages adjacent to rocky reefs on São Miguel Island (Azores, NE Atlantic) Opendataset
Difficulty 1/5 Under an hour Newbie friendliness 80/100
iobis/obis-network-datasets#909 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OHDSI/CohortConstructor#774 ·