Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Invalid value of type 'builtins.dict' error when copying figure in 6.0.0rc0 #4925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
LiamConnors opened this issue Dec 3, 2024 · 6 comments Β· Fixed by #4926
Closed

Invalid value of type 'builtins.dict' error when copying figure in 6.0.0rc0 #4925

LiamConnors opened this issue Dec 3, 2024 · 6 comments Β· Fixed by #4926
Assignees
Labels
bug something broken P1 needed for current cycle

Comments

@LiamConnors
Copy link
Member

LiamConnors commented Dec 3, 2024

The example below throws an error in 6.0.0rc0 but not in 5.24.1

    raise ValueError(
ValueError: 
    Invalid value of type 'builtins.dict' received for the 'x' property of scatter
        Received value: {'dtype': 'i2', 'bdata': 'oAelB6oHrwe0B7kHvgfDB8gHzQfSB9cH'}

    The 'x' property is an array that may be specified as a tuple,
    list, numpy array, or pandas Series
from dash import Dash, dcc, html
import plotly.express as px

import copy

app = Dash(__name__)

gapminder = px.data.gapminder().query("(country=='Canada') | (country=='United States') | (country=='Mexico')")

fig = px.line(gapminder, x="year", y="gdpPercap", color='country')
fig.update_yaxes(title_text='Year')
fig.update_xaxes(title_text='Adoption Rate')

# Default dimensions
fig.update_layout(
    margin=dict(l=60, r=0, t=0, b=60),
)

fig_custom_height = copy.deepcopy(fig)
fig_custom_height.update_layout(height=800)

fig_custom_short_height = copy.deepcopy(fig)
fig_custom_short_height.update_layout(height=200)

app.layout = [
                dcc.Graph(
                figure = fig_custom_height,
                ),
                dcc.Graph(
                figure = fig_custom_short_height,
            ),

]

if __name__ == '__main__':
    app.run_server(debug=True)

pip list output:

Package              Version
-------------------- -----------
blinker              1.9.0
certifi              2024.8.30
charset-normalizer   3.4.0
click                8.1.7
dash                 2.18.2
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table           5.0.0
Flask                3.0.3
idna                 3.10
importlib_metadata   8.5.0
itsdangerous         2.2.0
Jinja2               3.1.4
MarkupSafe           3.0.2
narwhals             1.15.2
nest-asyncio         1.6.0
numpy                2.1.3
packaging            24.2
pandas               2.2.3
pip                  23.2.1
plotly               6.0.0rc0
python-dateutil      2.9.0.post0
pytz                 2024.2
requests             2.32.3
retrying             1.3.4
setuptools           65.5.0
six                  1.16.0
tenacity             9.0.0
typing_extensions    4.12.2
tzdata               2024.2
urllib3              2.2.3
Werkzeug             3.0.6
zipp                 3.21.0
@gvwilson gvwilson added bug something broken P1 needed for current cycle labels Dec 3, 2024
@FBruzzesi
Copy link
Contributor

I was able to bisect it to the following commit: 960adb9
Specifically is_typed_array_spec was the only function checking for dict type.

@marthacryan
Copy link
Collaborator

@FBruzzesi Thank you for finding that! I think we can put those changes back in. I was not expecting the typed arrays to be input to validators anymore but I see that this is a case where they might be showing up for validation. If we bypass validation when we encounter typed array spec it should work, so maybe I'll just revert those changes.

@FBruzzesi
Copy link
Contributor

FBruzzesi commented Dec 3, 2024

I am running tests reverting those changes! I can open a PR if everything goes smooth :)

Edit: I wonder if there are specific tests worth adding

@gvwilson
Copy link
Contributor

gvwilson commented Dec 9, 2024

@marthacryan @FBruzzesi what's the status on this one now? thanks - @gvwilson

@marthacryan
Copy link
Collaborator

I approved the PR to fix this! @gvwilson should I go ahead and merge?

@gvwilson
Copy link
Contributor

gvwilson commented Dec 9, 2024

please!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P1 needed for current cycle
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants