Skip to content

Commit 56bb0d6

Browse files
committed
use more modern hv
1 parent a2216e8 commit 56bb0d6

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

docs/source/docs.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ on the *Play* :fa:`play` button or move the sliders.
5050
from adaptive.learner.learner1D import uniform_loss, default_loss
5151
import holoviews as hv
5252
import numpy as np
53+
5354
adaptive.notebook_extension()
54-
%output holomap='scrubber'
55+
hv.output(holomap="scrubber")
5556

5657
`adaptive.Learner1D`
5758
~~~~~~~~~~~~~~~~~~~~
5859

5960
.. jupyter-execute::
6061
:hide-code:
6162

62-
%%opts Layout [toolbar=None]
6363
def f(x, offset=0.07357338543088588):
6464
a = 0.01
6565
return x + a**2 / (a**2 + (x - offset)**2)
@@ -71,20 +71,23 @@ on the *Play* :fa:`play` button or move the sliders.
7171
x, y = [x_0, x_1], [y_0, y_1]
7272
else:
7373
x, y = [], []
74-
return hv.Scatter((x, y)).opts(style=dict(size=6, color='r'))
74+
return hv.Scatter((x, y)).opts(style=dict(size=6, color="r"))
7575

7676
def plot(learner, npoints):
7777
adaptive.runner.simple(learner, lambda l: l.npoints == npoints)
7878
return (learner.plot() * plot_loss_interval(learner))[:, -1.1:1.1]
7979

8080
def get_hm(loss_per_interval, N=101):
81-
learner = adaptive.Learner1D(f, bounds=(-1, 1),
82-
loss_per_interval=loss_per_interval)
81+
learner = adaptive.Learner1D(f, bounds=(-1, 1), loss_per_interval=loss_per_interval)
8382
plots = {n: plot(learner, n) for n in range(N)}
84-
return hv.HoloMap(plots, kdims=['npoints'])
83+
return hv.HoloMap(plots, kdims=["npoints"])
84+
85+
layout = (
86+
get_hm(uniform_loss).relabel("homogeneous samping")
87+
+ get_hm(default_loss).relabel("with adaptive")
88+
)
8589

86-
(get_hm(uniform_loss).relabel('homogeneous samping')
87-
+ get_hm(default_loss).relabel('with adaptive'))
90+
layout.opts(plot=dict(toolbar=None))
8891

8992
`adaptive.Learner2D`
9093
~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)