OverflowError: Python integer 256 out of bounds for uint8
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Jupyter Notebook
- Estrellas
- 853
- Forks
- 322
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en wfdb/io/annotation.py, en proc_core_fields, y utiliza el traceback y la invocación de demo4.py reportada para reproducir el OverflowError. Compara el resultado de rdann del script independiente con el comportamiento del notebook; la tarea estará terminada cuando demo4.py se ejecute correctamente con los datos de ejemplo sin el desbordamiento de uint8.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- data
- Tipo de issue
- Error
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 48/100