Return parallel instance with delayed function. Util function to use joblib only if available Parameters ---------- func : callable A function. %(n_jobs)s max_nbytes : int | str | None Threshold on the minimum size of arrays passed to the workers that
(
func,
n_jobs,
max_nbytes="auto",
pre_dispatch="n_jobs",
total=None,
prefer=None,
*,
max_jobs=None,
verbose=None,
)
| 22 | |
| 23 | @verbose |
| 24 | def parallel_func( |
| 25 | func, |
| 26 | n_jobs, |
| 27 | max_nbytes="auto", |
| 28 | pre_dispatch="n_jobs", |
| 29 | total=None, |
| 30 | prefer=None, |
| 31 | *, |
| 32 | max_jobs=None, |
| 33 | verbose=None, |
| 34 | ): |
| 35 | """Return parallel instance with delayed function. |
| 36 | |
| 37 | Util function to use joblib only if available |
| 38 | |
| 39 | Parameters |
| 40 | ---------- |
| 41 | func : callable |
| 42 | A function. |
| 43 | %(n_jobs)s |
| 44 | max_nbytes : int | str | None |
| 45 | Threshold on the minimum size of arrays passed to the workers that |
| 46 | triggers automated memory mapping. Can be an int in Bytes, |
| 47 | or a human-readable string, e.g., '1M' for 1 megabyte. |
| 48 | Use None to disable memmaping of large arrays. Use 'auto' to |
| 49 | use the value set using :func:`mne.set_memmap_min_size`. |
| 50 | pre_dispatch : int | str |
| 51 | See :class:`joblib.Parallel`. |
| 52 | total : int | None |
| 53 | If int, use a progress bar to display the progress of dispatched |
| 54 | jobs. This should only be used when directly iterating, not when |
| 55 | using ``split_list`` or :func:`np.array_split`. |
| 56 | If None (default), do not add a progress bar. |
| 57 | prefer : str | None |
| 58 | If str, can be ``"processes"`` or ``"threads"``. |
| 59 | See :class:`joblib.Parallel`. |
| 60 | |
| 61 | .. versionadded:: 0.18 |
| 62 | max_jobs : int | None |
| 63 | The upper limit of jobs to use. This is useful when you know ahead |
| 64 | of a the maximum number of calls into :class:`joblib.Parallel` that |
| 65 | you will possibly want or need, and the returned ``n_jobs`` should not |
| 66 | exceed this value regardless of how many jobs the user requests. |
| 67 | %(verbose)s INFO or DEBUG |
| 68 | will print parallel status, others will not. |
| 69 | |
| 70 | Returns |
| 71 | ------- |
| 72 | parallel: instance of joblib.Parallel or list |
| 73 | The parallel object. |
| 74 | my_func: callable |
| 75 | ``func`` if not parallel or delayed(func). |
| 76 | n_jobs: int |
| 77 | Number of jobs >= 1. |
| 78 | """ |
| 79 | should_print = logger.level <= logging.INFO |
| 80 | # for a single job, we don't need joblib |
| 81 | _validate_type(n_jobs, ("int-like", None)) |