From 1cf81e8a691329089eb47a4f0161d74d56d5eae9 Mon Sep 17 00:00:00 2001 From: yzhaoinuw Date: Thu, 11 Dec 2025 15:49:46 -0500 Subject: [PATCH] Fix: Default Mode In show_dash Causes TypeError 1. Fix the TypeError one encounters when using FigureResampler's show_dash method with the default mode, which is None. 2. Add test. --- plotly_resampler/figure_resampler/figure_resampler.py | 6 +++--- tests/test_figure_resampler.py | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/plotly_resampler/figure_resampler/figure_resampler.py b/plotly_resampler/figure_resampler/figure_resampler.py index 46f34c8d..93fa2916 100644 --- a/plotly_resampler/figure_resampler/figure_resampler.py +++ b/plotly_resampler/figure_resampler/figure_resampler.py @@ -530,9 +530,9 @@ def show_dash( available_modes = list(dash._jupyter.JupyterDisplayMode.__args__) + [ "inline_persistent" ] - assert ( - mode is None or mode in available_modes - ), f"mode must be one of {available_modes}" + if mode is None: + mode = "external" + assert mode in available_modes, f"mode must be one of {available_modes}" graph_properties = {} if graph_properties is None else graph_properties assert "config" not in graph_properties # There is a param for config if self["layout"]["autosize"] is True and self["layout"]["height"] is None: diff --git a/tests/test_figure_resampler.py b/tests/test_figure_resampler.py index d41b651a..d73f60c5 100644 --- a/tests/test_figure_resampler.py +++ b/tests/test_figure_resampler.py @@ -2024,3 +2024,11 @@ def test_manual_range_def(shared_xaxes): assert isinstance(ud, list) and len(ud) == 2 ud = fig._construct_update_data({"xaxis2.range": [2, 10], "xaxis.range": [5, 100]}) assert isinstance(ud, list) and len(ud) == 3 + + +def test_show_dash_with_default_mode(): + x = np.arange(100) + y = np.sin(x) + fig = FigureResampler(go.Figure()) + fig.add_trace(go.Scattergl(), hf_x=x, hf_y=y) + fig.show_dash(config={"scrollZoom": True}) # mode defaults to None \ No newline at end of file