OverflowError: Python integer 256 out of bounds for uint8
还没有人认领这个 Issue。
- #505 来自 @cbrnr —— 已关闭,未合并
评估
调研方向
从 wfdb/io/annotation.py 中的 proc_core_fields 开始,使用 traceback 和报告中的 demo4.py 调用来复现 OverflowError。将单独脚本中的 rdann 结果与 notebook 的行为进行比较;当 demo4.py 能够在示例数据上成功运行且不发生 uint8 溢出时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Jupyter Notebook
- 星标
- 853
- 派生
- 323
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
MIT-LCP/wfdb-python 的其他 Issue
-
`find_local_peaks` ignores the sample at `i + radius`, so points on a rising slope are returned as peaks可能已有人在做 @rmz-oz 于 5 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
MIT-LCP/wfdb-python#572 ·
-
难度 4/5 3-5 天 新手友好度 45/100
MIT-LCP/wfdb-python#568 ·
-
Add validation of segments when writing a `MultiRecord`可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 48/100
MIT-LCP/wfdb-python#557 ·
-
难度 2/5 1-3 小时 新手友好度 58/100
MIT-LCP/wfdb-python#554 ·
-
难度 4/5 3-5 天 新手友好度 35/100
MIT-LCP/wfdb-python#545 ·
查看 MIT-LCP/wfdb-python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
py-econometrics/pyfixest#1883 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 64/100
agrc/palletjack#208 ·
-
Opt-out request未关闭
难度 1/5 1 小时以内 新手友好度 62/100
bigcode-project/opt-out-v2#13787 ·
-
难度 2/5 1 小时以内 新手友好度 66/100
sourcey/startup-credits#1684 · 1 条评论 ·
维护者通常 9 天内回复