This is probably useful for testing.
This will only work with the
SequentialExecutor or an executor that does a better job of pickling, I marked it as a WIP because of this reason.
import adaptive import numpy as np import holoviews as hv adaptive.notebook_extension() def f(x): return x**2 learner = adaptive.Learner1D(f, (-1, 1)) runner = adaptive.Runner(learner, adaptive.runner.SequentialExecutor(), goal=lambda l: l.loss() < 0.00001, timeit=True)
we can then easily generate a plot:
def running_mean(x, N): cumsum = np.cumsum(np.insert(x, 0, 0)) return (cumsum[N:] - cumsum[:-N]) / float(N) (hv.Curve(running_mean(runner.times['add_point'], 200), label='add_point') * hv.Curve(running_mean(runner.times['choose_points'], 200), label='choose_points') * hv.Curve(running_mean(runner.times['function'], 200), label='function'))
For the future
The runner can also be made smarter. For example, it could notice that
choose_points takes longer than evaluating the
function, then it could choose to choose more points at once.