adaptive.utils module#

class adaptive.utils.SequentialExecutor[source]#

Bases: Executor

A trivial executor that runs functions synchronously.

This executor is mainly for testing.

map(fn, *iterable, timeout=None, chunksize=1)[source]#

Returns an iterator equivalent to map(fn, iter).

  • fn โ€“ A callable that will take as many arguments as there are passed iterables.

  • timeout โ€“ The maximum number of seconds to wait. If None, then there is no limit on the wait time.

  • chunksize โ€“ The size of the chunks the iterable will be broken into before being passed to a child process. This argument is only used by ProcessPoolExecutor; it is ignored by ThreadPoolExecutor.


map(func, *iterables) but the calls may be evaluated out-of-order.

Return type:

An iterator equivalent to

  • TimeoutError โ€“ If the entire result iterator could not be generated before the given timeout.

  • Exception โ€“ If fn(*args) raises for any values.


Clean-up the resources associated with the Executor.

It is safe to call this method several times. Otherwise, no other methods can be called after this one.

  • wait โ€“ If True then shutdown will not return until all running futures have finished executing and the resources used by the executor have been reclaimed.

  • cancel_futures โ€“ If True then shutdown will cancel all pending futures. Futures that are completed or running will not be cancelled.

submit(fn: Callable, *args, **kwargs) Future[source]#

Submits a callable to be executed with the given arguments.

Schedules the callable to be executed as fn(*args, **kwargs) and returns a Future instance representing the execution of the callable.


A Future representing the given call.

adaptive.utils.assign_defaults(function, df, function_prefix: str = 'function.')[source]#
adaptive.utils.cache_latest(f: Callable) Callable[source]#

Cache the latest return value of the function and add it as โ€˜self._cache[f.__name__]โ€™.

adaptive.utils.copy_docstring_from(other: Callable) Callable[source]#
adaptive.utils.daskify(client: AsyncDaskClient, cache: bool = False) Callable[[Callable[..., T]], Callable[..., Awaitable[T]]][source]#
adaptive.utils.load(fname: str, compress: bool = True) Any[source]#
adaptive.utils.named_product(**items: Sequence[Any])[source]#
adaptive.utils.partial_function_from_dataframe(function, df, function_prefix: str = 'function.')[source]#
adaptive.utils.restore(*learners) Iterator[None][source]# str, data: Any, compress: bool = True) bool[source]#