Skip to content

Commit 1439d08

Browse files
committed
🥵 add tests + cleanup
1 parent 4f50bb6 commit 1439d08

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

plotly_resampler/figure_resampler/figure_resampler.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,14 @@ def show_dash(
355355
constructor via the ``show_dash_kwargs`` argument.
356356
357357
"""
358+
available_modes = ["external", "inline", "inline_persistent", "jupyterlab"]
359+
assert mode is None or mode in available_modes, (
360+
f"mode must be one of {available_modes}"
361+
)
358362
graph_properties = {} if graph_properties is None else graph_properties
359363
assert "config" not in graph_properties.keys() # There is a param for config
360364
# 1. Construct the Dash app layout
361-
if mode is "inline_persistent":
365+
if mode == "inline_persistent":
362366
# Inline persistent mode: we display a static image of the figure when the
363367
# app is not reachable
364368
# Note: this is the "inline" behavior of JupyterDashInlinePersistentOutput

tests/test_figure_resampler.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,25 @@ def test_stop_server_inline():
610610
proc.terminate()
611611

612612

613+
def test_stop_server_inline_persistent():
614+
# mostly written to test the check_update_figure_dict whether the inline + height
615+
# line option triggers
616+
fr = FigureResampler(go.Figure())
617+
n = 100_000
618+
x = np.arange(n)
619+
y = np.sin(x)
620+
fr.add_trace(go.Scattergl(name="test"), hf_x=x, hf_y=y)
621+
fr.update_layout(height=900)
622+
fr.stop_server()
623+
proc = multiprocessing.Process(target=fr.show_dash, kwargs=dict(mode="inline_persistent"))
624+
proc.start()
625+
import time
626+
627+
time.sleep(3)
628+
fr.stop_server()
629+
proc.terminate()
630+
631+
613632
def test_stop_server_external():
614633
fr = FigureResampler(go.Figure())
615634
n = 100_000

0 commit comments

Comments
 (0)