parallelize¶
- parallelize(func: callable, ins: Iterable, verbose: int = 10, n_jobs: int = None, **kwargs) list | None[source][source]¶
Parallelize a function to run on multiple processors.
This function is a wrapper for joblib.Parallel. It will automatically determine the number of jobs to run in parallel based on the number of cores available on the system. It will also automatically set the temp_folder and max_nbytes parameters for joblib.Parallel based on the MNE_CACHE_DIR and MNE_MEMMAP_MIN_SIZE parameters in mne-python’s configuration file.
Notes
If the elements of the par_var iterable are tuples, the function will be called with the tuple unpacked, setting each item in the tuple to be assigned to a separate argument. If the elements of the par_var iterable are not tuples, the function will be called with the element as the first argument.
- Parameters:
func (
callable) – The function to parallelizeins (
Iterable) – The iterable to parallelize overn_jobs (
int) – The number of jobs to run in parallel. If None, will use all available cores. If -1, will use all available cores.**kwargs – Additional keyword arguments to pass to the function
verbose (int)
- Returns:
The output of the function for each element in par_var
- Return type:
Examples
>>> def square(x): ... return x ** 2 >>> parallelize(square, [1, 2, 3]) [1, 4, 9]