Skip to content

Commit 39196b1

Browse files
authored
Fix HoloViews opts deprecation warnings (#357)
1 parent 3cd17f3 commit 39196b1

File tree

7 files changed

+14
-29
lines changed

7 files changed

+14
-29
lines changed

adaptive/learner/learner2D.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -818,12 +818,9 @@ def plot(self, n=None, tri_alpha=0):
818818
else:
819819
im = hv.Image([], bounds=lbrt)
820820
tris = hv.EdgePaths([])
821-
822-
im_opts = {"cmap": "viridis"}
823-
tri_opts = {"line_width": 0.5, "alpha": tri_alpha}
824-
no_hover = {"plot": {"inspection_policy": None, "tools": []}}
825-
826-
return im.opts(style=im_opts) * tris.opts(style=tri_opts, **no_hover)
821+
return im.opts(cmap="viridis") * tris.opts(
822+
line_width=0.5, alpha=tri_alpha, tools=[]
823+
)
827824

828825
def _get_data(self) -> dict[tuple[float, float], Float | np.ndarray]:
829826
return self.data

adaptive/learner/learnerND.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -932,12 +932,9 @@ def plot(self, n=None, tri_alpha=0):
932932
else:
933933
im = hv.Image([], bounds=lbrt)
934934
tris = hv.EdgePaths([])
935-
936-
im_opts = {"cmap": "viridis"}
937-
tri_opts = {"line_width": 0.5, "alpha": tri_alpha}
938-
no_hover = {"plot": {"inspection_policy": None, "tools": []}}
939-
940-
return im.opts(style=im_opts) * tris.opts(style=tri_opts, **no_hover)
935+
return im.opts(cmap="viridis") * tris.opts(
936+
line_width=0.5, alpha=tri_alpha, tools=[]
937+
)
941938

942939
def plot_slice(self, cut_mapping, n=None):
943940
"""Plot a 1D or 2D interpolated slice of a N-dimensional function.
@@ -1005,7 +1002,7 @@ def plot_slice(self, cut_mapping, n=None):
10051002
else:
10061003
im = hv.Image([], bounds=lbrt)
10071004

1008-
return im.opts(style={"cmap": "viridis"})
1005+
return im.opts(cmap="viridis")
10091006
else:
10101007
raise ValueError("Only 1 or 2-dimensional plots can be generated.")
10111008

@@ -1199,10 +1196,7 @@ def plot_isoline(self, level=0.0, n=None, tri_alpha=0):
11991196

12001197
vertices, lines = self._get_iso(level, which="line")
12011198
paths = [[vertices[i], vertices[j]] for i, j in lines]
1202-
contour = hv.Path(paths)
1203-
1204-
contour_opts = {"color": "black"}
1205-
contour = contour.opts(style=contour_opts)
1199+
contour = hv.Path(paths).opts(color="black")
12061200
return plot * contour
12071201

12081202
def plot_isosurface(self, level=0.0, hull_opacity=0.2):

adaptive/learner/skopt_learner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ def plot(self, nsamples=200):
9898
xsp = self.space.transform(xs.reshape(-1, 1).tolist())
9999
y_pred, sigma = model.predict(xsp, return_std=True)
100100
# Plot model prediction for function
101-
curve = hv.Curve((xs, y_pred)).opts(style={"line_dash": "dashed"})
101+
curve = hv.Curve((xs, y_pred)).opts(line_dash="dashed")
102102
# Plot 95% confidence interval as colored area around points
103103
area = hv.Area(
104104
(xs, y_pred - 1.96 * sigma, y_pred + 1.96 * sigma),
105105
vdims=["y", "y2"],
106-
).opts(style={"alpha": 0.5, "line_alpha": 0})
106+
).opts(alpha=0.5, line_alpha=0)
107107

108108
else:
109109
area = hv.Area([])

docs/source/algorithms_and_examples.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def plot_loss_interval(learner):
9898
x, y = [x_0, x_1], [y_0, y_1]
9999
else:
100100
x, y = [], []
101-
return hv.Scatter((x, y)).opts(style=dict(size=6, color="r"))
101+
return hv.Scatter((x, y)).opts(size=6, color="r")
102102
103103
104104
def plot(learner, npoints):
@@ -114,7 +114,7 @@ def get_hm(loss_per_interval, N=101):
114114
plot_homo = get_hm(uniform_loss).relabel("homogeneous sampling")
115115
plot_adaptive = get_hm(default_loss).relabel("with adaptive")
116116
layout = plot_homo + plot_adaptive
117-
layout.opts(plot=dict(toolbar=None))
117+
layout.opts(toolbar=None)
118118
```
119119

120120
## {class}`adaptive.Learner2D`

docs/source/tutorial/tutorial.LearnerND.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ dm = dm.redim.values(
9494
9595
# In a notebook one would run `dm` however we want a statically generated
9696
# html, so we use a HoloMap to display it here
97-
dynamicmap_to_holomap(dm).options(hv.opts.Path(framewise=True))
97+
dynamicmap_to_holomap(dm).opts(hv.opts.Path(framewise=True))
9898
```
9999

100100
The plots show some wobbles while the original function was smooth, this is a result of the fact that the learner chooses points in 3 dimensions and the simplices are not in the same face as we try to interpolate our lines.

docs/source/tutorial/tutorial.advanced-topics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ adaptive.runner.replay_log(reconstructed_learner, runner.log)
316316
```
317317

318318
```{code-cell} ipython3
319-
learner.plot().Scatter.I.opts(style=dict(size=6)) * reconstructed_learner.plot()
319+
learner.plot().Scatter.I.opts(size=6) * reconstructed_learner.plot()
320320
```
321321

322322
## Adding coroutines

setup.cfg

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)