Skip to content

Commit 1cf81e8

Browse files
committed
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.
1 parent 9483326 commit 1cf81e8

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

plotly_resampler/figure_resampler/figure_resampler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,9 @@ def show_dash(
530530
available_modes = list(dash._jupyter.JupyterDisplayMode.__args__) + [
531531
"inline_persistent"
532532
]
533-
assert (
534-
mode is None or mode in available_modes
535-
), f"mode must be one of {available_modes}"
533+
if mode is None:
534+
mode = "external"
535+
assert mode in available_modes, f"mode must be one of {available_modes}"
536536
graph_properties = {} if graph_properties is None else graph_properties
537537
assert "config" not in graph_properties # There is a param for config
538538
if self["layout"]["autosize"] is True and self["layout"]["height"] is None:

tests/test_figure_resampler.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,3 +2024,11 @@ def test_manual_range_def(shared_xaxes):
20242024
assert isinstance(ud, list) and len(ud) == 2
20252025
ud = fig._construct_update_data({"xaxis2.range": [2, 10], "xaxis.range": [5, 100]})
20262026
assert isinstance(ud, list) and len(ud) == 3
2027+
2028+
2029+
def test_show_dash_with_default_mode():
2030+
x = np.arange(100)
2031+
y = np.sin(x)
2032+
fig = FigureResampler(go.Figure())
2033+
fig.add_trace(go.Scattergl(), hf_x=x, hf_y=y)
2034+
fig.show_dash(config={"scrollZoom": True}) # mode defaults to None

0 commit comments

Comments
 (0)