amep.utils.compute_parallel#

amep.utils.compute_parallel(func: callable, chunks: list | ndarray | tuple, *args, njobs: int = 2, verbose: bool = False, **kwargs) list#

Calls the given function for all given chunks in parallel with a given number of parallel jobs.

Parameters:
  • func (callable) – Function to call for each chunk. The first argument of func must be the chunk.

  • chunks (list or np.ndarray or tuple) – Iterable of chunks.

  • *args – Additional arguments forwarded to func.

  • njobs (int, optional) – Number of workers used for the parallelization. If this number exceeds the number of CPU cores, it is set to the number of available CPU cores. The default is 2.

  • verbose (bool, optional) – If True, a progress bar is shown. The default is False.

  • **kwargs – Other keyword arguments are forwarded to func.

Returns:

results – List of results from each of the workers.

Return type:

list