Skip to content

Commit 2a7f8d9

Browse files
authored
Run black
1 parent 65bf5fe commit 2a7f8d9

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -388,32 +388,28 @@ The function to be learned is `async_h`, which submits `h` as a coroutine to the
388388
```{code-cell} ipython3
389389
import time
390390
391+
391392
def h(x, offset=offset):
392393
a = 0.01
393394
x = g(x)
394395
return x + a**2 / (a**2 + (x - offset) ** 2)
395396
397+
396398
def g(x):
397399
time.sleep(random.randrange(5))
398400
return x**2
399401
402+
400403
async def async_h(x):
401404
return await client.submit(h, x)
402405
```
403406

404407
When provide the asynchronous function to the `learner` and run it via `AsyncRunner`.
405408

406409
```{code-cell} ipython3
407-
learner = adaptive.Learner1D(
408-
async_h,
409-
bounds=(-1, 1)
410-
)
410+
learner = adaptive.Learner1D(async_h, bounds=(-1, 1))
411411
412-
runner = adaptive.AsyncRunner(
413-
learner,
414-
goal=lambda l: l.loss() < 0.01,
415-
ntasks=20
416-
)
412+
runner = adaptive.AsyncRunner(learner, goal=lambda l: l.loss() < 0.01, ntasks=20)
417413
```
418414

419415
We await for the runner to finish, and then plot the result.

0 commit comments

Comments
 (0)