[BUG]: Integer and string properties reject NumPy scalars
Los mantenedores suelen responder en 3 días
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 70/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Área
- backend, data-visualization
Línea de trabajo
Empieza leyendo IntegerValidator y StringValidator, que según el issue rechazan escalares de NumPy, y compara sus comprobaciones con NumberValidator. Reproduce los ejemplos para name, text, nticks y nbinsx; después, busca pruebas de validadores que cubran los enteros y números de Python. La tarea estará terminada cuando se acepten en esas propiedades los valores de NumPy descritos en el issue y se siga cubriendo el comportamiento de validación existente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
Graph object properties validated as integers (such as layout.xaxis.nticks, histogram.nbinsx and layout.updatemenus[].active) reject NumPy integer scalars, and properties validated as non-strict strings (such as name and text) reject NumPy integer and float32 scalars. Python int and float values of the same number are accepted, and number properties such as marker.size already accept NumPy scalars.
This breaks a common pattern: building one trace per value of a DataFrame column with Series.unique(), which returns NumPy scalars.
Expected: NumPy integers are accepted wherever a Python int is, and NumPy numbers are converted to strings the same way Python numbers are.
Steps to reproduce
import numpy as np
import pandas as pd
import plotly.graph_objects as go
df = pd.DataFrame({"year": [2020, 2021], "v": [1, 2]})
for label, call in [
("name", lambda: go.Scatter(name=df.year.unique()[0])),
("text", lambda: go.Scatter(text=np.float32(1.5))),
("nticks", lambda: go.Layout(xaxis_nticks=np.int64(5))),
("nbinsx", lambda: go.Histogram(nbinsx=np.int32(10))),
]:
try:
call()
print(label, "ok")
except ValueError as error:
print(label, str(error).splitlines()[1].strip())
Actual:
name Invalid value of type 'numpy.int64' received for the 'name' property of scatter
text Invalid value of type 'numpy.float32' received for the 'text' property of scatter
nticks Invalid value of type 'numpy.int64' received for the 'nticks' property of layout.xaxis
nbinsx Invalid value of type 'numpy.int32' received for the 'nbinsx' property of histogram
Expected:
name ok
text ok
nticks ok
nbinsx ok
Notes
IntegerValidator checks isinstance(v, int) and StringValidator checks isinstance(v, (int, float)). NumPy integer types are not subclasses of int, so they fail both checks, while NumberValidator checks numbers.Number and accepts them. The error message for string properties says "A number that will be converted to a string", which a NumPy number is.
Reproduced with plotly 7.1.0 and current main (38374acd), NumPy 2.x, Python 3.12.
- Lenguaje dominante
- Python
- Estrellas
- 18.9k
- Forks
- 2.9k
- Merge medio
- 1 d 9 h
- PR fusionados (30 d)
- 10
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
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.
Más de plotly/plotly.py
-
[BUG]: Duplicate `FigureWidget` import code in `graph_objects` and `graph_objs`Posiblemente ocupada @DawnofGenX la tomó hace 1 día. Abiertobug P3 size: 1
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 3 días
-
[BUG]: validate_colors and convert_colors_to_same_type modify the colors passed to themPosiblemente ocupada @Enesuygurs la tomó hace 6 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 3 días
-
to_typed_array_spec encodes bdata in host byte order; plotly.js always decodes it as little-endianPosiblemente ocupada @Vikram12301 la tomó hace 6 días. Abiertobug P3 size: 1
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
plotly/plotly.py#5837 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
[BUG]: NaT inside a datetime64 array serializes as the string "NaT" instead of nullPosiblemente ocupada @senanurcetin la tomó hace 8 días. Abiertobug P3 size: 1
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
plotly/plotly.py#5829 · 3 comentarios ·
Los mantenedores suelen responder en 3 días
-
[BUG]: Single-color requests raise ZeroDivisionError in palette helpersPosiblemente ocupada @MokiMeow la tomó hace 18 días. Abiertobug P3 size: 1
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
plotly/plotly.py#5805 · 1 comentario ·
Los mantenedores suelen responder en 3 días
Todos los issues de plotly/plotly.py
Issues similares
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
glossyio/traffic-monitor#264 ·
Los mantenedores suelen responder en 1 día
-
Add self-hostAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
Atarity/deploy-your-own-saas#102 ·
-
[Bug]: RDFlex silently drops the covariate adjustment when the outcome or treatment column is integer-typedPosiblemente ocupada @vrjdev la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
DoubleML/doubleml-for-py#424 ·
Los mantenedores suelen responder en 1 día
-
agentic-dmx docs enhancement
Dificultad 1/5 1-3 horas Aptitud para principiantes 86/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
521xueweihan/HelloGitHub#4150 ·