File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44import pytest
55from scipy .spatial import ConvexHull
66
7+ import adaptive .notebook_integration as notebook_integration
78from adaptive .learner .base_learner import uses_nth_neighbors
89from adaptive .learner .learnerND import (
910 LearnerND ,
@@ -152,9 +153,28 @@ def f_vec(x):
152153 assert np .isclose (result [1 ], 0.0 )
153154
154155
156+ def test_learnerND_1d_plot_requires_holoviews (monkeypatch ):
157+ """Test that plotting fails with a clear error without holoviews."""
158+
159+ import_module = notebook_integration .importlib .import_module
160+
161+ def missing_holoviews (name ):
162+ if name == "holoviews" :
163+ raise ModuleNotFoundError
164+ return import_module (name )
165+
166+ monkeypatch .setattr (notebook_integration .importlib , "import_module" , missing_holoviews )
167+
168+ learner = make_1d_learner ()
169+ tell_1d_points (learner )
170+
171+ with pytest .raises (RuntimeError , match = "holoviews is not installed; plotting is disabled." ):
172+ learner .plot ()
173+
174+
155175def test_learnerND_1d_plot ():
156176 """Test that 1D plot() does not crash."""
157- import holoviews as hv
177+ hv = pytest . importorskip ( "holoviews" )
158178
159179 hv .extension ("bokeh" )
160180 learner = make_1d_learner ()
You can’t perform that action at this time.
0 commit comments