Incompatibility of python 3.10 with adaptive(asyncio)
When executing an adaptive example, the runner fails due to a keyword error.
This error has been found before. It requires to remove the loop
keyword since it is not anymore supported by python 3.10.
The minimal code that produces the problem is:
import adaptive
import numpy as np
adaptive.notebook_extension()
def ring(xy):
x, y = xy
a = 0.2
return x + np.exp(-(x**2 + y**2 - 0.75**2)**2/a**4)
learner = adaptive.Learner2D(ring, bounds=[(-1, 1), (-1, 1)])
runner = adaptive.Runner(learner, goal=lambda l: l.loss() < 0.01)
runner.task.result()
The error is:
TypeError Traceback (most recent call last)
Input In [27], in <cell line: 1>()
----> 1 runner.task.result()
File /opt/conda/lib/python3.10/site-packages/adaptive/runner.py:584, in AsyncRunner.status(self)
579 """Return the runner status as a string.
580
581 The possible statuses are: running, cancelled, failed, and finished.
582 """
583 try:
--> 584 self.task.result()
585 except asyncio.CancelledError:
586 return "cancelled"
File /opt/conda/lib/python3.10/site-packages/adaptive/runner.py:584, in AsyncRunner.status(self)
579 """Return the runner status as a string.
580
581 The possible statuses are: running, cancelled, failed, and finished.
582 """
583 try:
--> 584 self.task.result()
585 except asyncio.CancelledError:
586 return "cancelled"
File /opt/conda/lib/python3.10/site-packages/adaptive/runner.py:645, in AsyncRunner._run(self)
643 while not self.goal(self.learner):
644 futures = self._get_futures()
--> 645 done, _ = await asyncio.wait(
646 futures, return_when=first_completed, loop=self.ioloop
647 )
648 self._process_futures(done)
649 finally:
TypeError: wait() got an unexpected keyword argument 'loop'