OverflowError: Python integer 256 out of bounds for uint8
まだ誰も着手していません。
- #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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 が 3 日前に担当しました。 オープン
難易度 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`対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
MIT-LCP/wfdb-python#557 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 58/100
MIT-LCP/wfdb-python#554 ·
-
WFDB path ignoredオープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
MIT-LCP/wfdb-python#545 ·
MIT-LCP/wfdb-python の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
CliMA/ClimaArtifacts#184 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
google/libaddressinput#255 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
Loading and saving back from file with netcdf fails対応中かも @mokashang が今日担当しました。 オープンbug topic-backends
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
pydata/xarray#11672 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信