[BUG] numpy array not correctly read back from figure data
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- numpy, plotly, python
- Área
- data-visualization
Línea de trabajo
Empieza ejecutando la reproducción de Dash proporcionada con Python 3.12, numpy 2.2.5, plotly 6.1.1 y las versiones de Dash indicadas; después, inspecciona los datos de la figura devueltos mediante el callback State. Compara los valores de x e y con los arrays originales; se considera terminado cuando los arrays no compatibles generan una excepción o se devuelven como arrays de numpy o listas válidas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Please provide us your environment, so we can easily reproduce the issue:
Windows 10, python 3.12
dash 3.0.4
dash-core-components 2.0.0
dash-html-components 2.0.0
plotly 6.1.1
numpy 2.2.5
Describe the bug
When I create a go.Figure and add a trace with x and/or y being numpy arrays, the plot is created correctly.
However, when I want to read back the data, some representation of the numpy array is provided as dictionary: {‘dtype’: ‘f8’, ‘bdata’: ‘AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAhAAAAAAAAAEEAAAAAAAAAUQA==’, ‘_inputArray’: {‘0’: 1, ‘1’: 2, ‘2’: 3, ‘3’: 4, ‘4’: 5, ‘bdata’: ‘AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAhAAAAAAAAAEEAAAAAAAAAUQA==’, ‘dtype’: ‘f8’, ‘shape’: ‘5’}}
As also described in https://community.plotly.com/t/changed-behaviour-in-dash-2-18-2-using-numpy-1-26-4-when-reading-figure-into-callback-on-linux/90614
import dash
from dash import dcc, html, Input, Output, State
import plotly.graph_objs as go
import numpy as np
# Initialize the Dash app
app = dash.Dash(__name__)
# Create some sample data using numpy
x_data = np.array([1.0, 2.0, 3.0, 4.0, 5.0])
y_data = np.array([2.0, 1.5, 3.5, 2.0, 5.0])
# Define the layout of the app
app.layout = html.Div([
dcc.Graph(id='scatter-plot'),
html.Button('Generate Plot', id='generate-button', n_clicks=0),
html.Button('Print Data', id='print-button', n_clicks=0)
])
# Callback to generate the ScatterGL plot
@app.callback(
Output('scatter-plot', 'figure'),
Input('generate-button', 'n_clicks')
)
def update_figure(n_clicks):
# Create a ScatterGL trace
trace = go.Scattergl(
x=x_data,
y=y_data,
mode='markers',
marker=dict(size=10, color='blue')
)
# Create the figure
fig = go.Figure(data=[trace])
fig.update_layout(title='ScatterGL Plot', xaxis_title='X Axis', yaxis_title='Y Axis')
return fig
# Callback to print the x and y data from the figure
@app.callback(
Output('print-button', 'children'),
Input('print-button', 'n_clicks'),
State('scatter-plot', 'figure')
)
def print_data(n_clicks, figure):
if n_clicks > 0 and figure is not None:
# Extract the x and y data from the figure
x_values = figure['data'][0]['x']
y_values = figure['data'][0]['y']
# Print the x and y values
print("X values:", x_values)
print("Y values:", y_values)
return "Print Data"
# Run the app
if __name__ == '__main__':
app.run_server(debug=True)
Expected behavior
A) Throw an Exception when numpy arrays are not supported
B) If numpy arrays are supported return the numpy array or the numpy array converted to a valid list
- Lenguaje dominante
- Python
- Estrellas
- 24.5k
- Forks
- 2.3k
- Merge medio
- 3 d 7 h
- PR fusionados (30 d)
- 30
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/dash
-
P2 plotly-internal size: 1 task
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Extract graph schema validation into properly named testPosiblemente ocupada @Nice6042 la tomó hace 90 días. Abiertogood first issue P3 size: 1 task
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
plotly/dash#3735 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
[BUG] Patch.update mutates a shared mapping and rewrites earlier mergesPosiblemente ocupada @peterolkhov la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
[BUG] dcc.Dropdown: virtualized list keeps the height measured at opening when options grow while the menu is openPosiblemente ocupada @KoolADE85 la tomó hace 2 días. Abiertobug P3 size: 1
plotly/dash#4131 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[BUG] `set_props` streamingPosiblemente ocupada @BSd3v la tomó hace 5 días. Abiertobug P3 size: 1
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
plotly/dash#4127 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de plotly/dash
Issues similares
-
[BUG] HTTP lifecycle dispatch treats a NO_PROXY-only environment as corporate egress and skips the resolve-and-pinned sessionPosiblemente ocupada @bodapatisaikrishna la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
[integration]: NoMacSandboxAbiertoexternal
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
langchain-ai/docs#7652 ·
Los mantenedores suelen responder en 1 día
-
[oblt-aw][autodoc] Document new e2e-secret-leak-artifacts workflow and update e2e-all leaf listAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
elastic/oblt-aw#2513 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
amd/gaia#7326 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
NCAR/CLM-Tutorial#113 · 1 comentario ·
Los mantenedores suelen responder en 1 día