pulse2percept.utils.parallel¶
Functions
parfor (func, in_list[, out_shape, n_jobs, …]) |
Parallel for loop for NumPy arrays |
-
pulse2percept.utils.parallel.
parfor
(func, in_list, out_shape=None, n_jobs=-1, engine=None, scheduler='threading', func_args=[], func_kwargs={})[source]¶ Parallel for loop for NumPy arrays
Parameters: - func (callable) – The function to apply to each item in the array. Must have the form:
func(arr, idx, *args, *kwargs) where arr is an ndarray and idx is an
index into that array (a tuple). The Return of
func
needs to be one item (e.g. float, int) per input item. - in_list (list) – All legitimate inputs to the function to operate over.
- out_shape (int or tuple of ints, optional) – If set, output will be reshaped accordingly. The new shape should be compatible with the original shape. If an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions.
- n_jobs (integer, optional, default: 1) – The number of jobs to perform in parallel. -1 to use all cpus
- engine (str, optional, default: JobLib or Dask (if available), else serial) – {‘dask’, ‘joblib’, ‘serial’} The last one is useful for debugging – runs the code without any parallelization.
- scheduler (str, optional, default: 'threading') – Which scheduler to use (irrelevant for ‘serial’ engine): - ‘threading’: a scheduler backed by a thread pool - ‘multiprocessing’: a scheduler backed by a process pool
- *func_args (list, optional) – Positional arguments to
func
- **func_kwargs (dict, optional) – Keyword arguments to
func
Returns: ndarray – NumPy array of identical shape to
arr
Note
Equivalent to pyAFQ version (blob e20eaa0 from June 3, 2016): https://github.com/arokem/pyAFQ/blob/master/AFQ/utils/parallel.py
- func (callable) – The function to apply to each item in the array. Must have the form:
func(arr, idx, *args, *kwargs) where arr is an ndarray and idx is an
index into that array (a tuple). The Return of