proc_array

proc_array(func: callable, arr_in: ndarray, axes: int | tuple[int] = 0, n_jobs: int = None, desc: str = 'Slices', inplace: bool = True, **kwargs) ndarray[source][source]

Execute a function in parallel over slices of an array

Parameters:
  • func (callable) – The function to execute

  • arr_in (np.ndarray) – The array to slice

  • axes (int | tuple[int]) – The axes to slice over

  • n_jobs (int) – The number of jobs to run in parallel

  • desc (str) – The description to use for the progress bar

  • inplace (bool) – Whether to modify the input array in place

Returns:

The output of the function, same shape as the input array

Return type:

np.ndarray

Examples

>>> def square(x):
...     return x ** 2
>>> proc_array(square, np.arange(10))
array([ 0,  1,  4,  9, 16, 25, 36, 49, 64, 81])