...
|
...
|
@@ -175,11 +175,12 @@
|
175
|
175
|
"metadata": {},
|
176
|
176
|
"outputs": [],
|
177
|
177
|
"source": [
|
178
|
|
- "def func(xy):\n",
|
|
178
|
+ "def func(xy, wait=True):\n",
|
179
|
179
|
" import numpy as np\n",
|
180
|
180
|
" from time import sleep\n",
|
181
|
181
|
" from random import random\n",
|
182
|
|
- " sleep(random())\n",
|
|
182
|
+ " if wait:\n",
|
|
183
|
+ " sleep(random())\n",
|
183
|
184
|
" x, y = xy\n",
|
184
|
185
|
" a = 0.2\n",
|
185
|
186
|
" return x + np.exp(-(x**2 + y**2 - 0.75**2)**2/a**4)\n",
|
...
|
...
|
@@ -204,7 +205,7 @@
|
204
|
205
|
"source": [
|
205
|
206
|
"%%output size=100\n",
|
206
|
207
|
"%%opts Contours (alpha=0.3)\n",
|
207
|
|
- "from adaptive.learner import *\n",
|
|
208
|
+ "import holoviews as hv\n",
|
208
|
209
|
"\n",
|
209
|
210
|
"def plot(learner):\n",
|
210
|
211
|
" tri = learner.ip().tri\n",
|
...
|
...
|
@@ -230,7 +231,7 @@
|
230
|
231
|
"learner2 = adaptive.learner.Learner2D(func, bounds=[(-1, 1), (-1, 1)])\n",
|
231
|
232
|
"lin = np.linspace(-1, 1, len(learner.points)**0.5)\n",
|
232
|
233
|
"xy = [(x, y) for x in lin for y in lin]\n",
|
233
|
|
- "learner2.add_data(xy, map(func, xy))\n",
|
|
234
|
+ "learner2.add_data(xy, map(partial(func, wait=False), xy))\n",
|
234
|
235
|
"learner2.plot().relabel('Homogeneous grid') + learner.plot().relabel('With adaptive')"
|
235
|
236
|
]
|
236
|
237
|
},
|
...
|
...
|
@@ -275,7 +276,7 @@
|
275
|
276
|
"metadata": {},
|
276
|
277
|
"outputs": [],
|
277
|
278
|
"source": [
|
278
|
|
- "learner = adaptive.AverageLearner(g, None, 0.01)\n",
|
|
279
|
+ "learner = adaptive.learner.AverageLearner(g, None, 0.01)\n",
|
279
|
280
|
"runner = adaptive.Runner(learner, goal=lambda l: l.loss() < 1)\n",
|
280
|
281
|
"adaptive.live_plot(runner)"
|
281
|
282
|
]
|
...
|
...
|
@@ -342,9 +343,8 @@
|
342
|
343
|
"metadata": {},
|
343
|
344
|
"outputs": [],
|
344
|
345
|
"source": [
|
345
|
|
- "from cquad import Learner\n",
|
346
|
|
- "learner = Learner(f24, bounds=(0, 3), tol=1e-3)\n",
|
347
|
|
- "runner = adaptive.Runner(learner, goal=lambda l: l.done())"
|
|
346
|
+ "learner = adaptive.learner.IntegratorLearner(f24, bounds=(0, 3), tol=1e-10)\n",
|
|
347
|
+ "runner = adaptive.Runner(learner, executor=adaptive.runner.SequentialExecutor(), goal=lambda l: l.done())"
|
348
|
348
|
]
|
349
|
349
|
},
|
350
|
350
|
{
|