Skip to content

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

Closed

Description

@LiamConnors

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

Activity

  1. added
    bug
    P1
    on Dec 3, 2024
  2. FBruzzesi commented on Dec 3, 2024

    @FBruzzesi
    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.

  3. marthacryan commented on Dec 3, 2024

    @marthacryan
    Contributor

    @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.

  4. FBruzzesi commented on Dec 3, 2024

    @FBruzzesi
    Contributor

    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

  5. gvwilson commented on Dec 9, 2024

    @gvwilson
    Contributor

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

  6. marthacryan commented on Dec 9, 2024

    @marthacryan
    Contributor

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

  7. gvwilson commented on Dec 9, 2024

    @gvwilson
    Contributor

    please!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions