Map a function across all blocks of a dask array. Note that ``map_blocks`` will attempt to automatically determine the output array type by calling ``func`` on 0-d versions of the inputs. Please refer to the ``meta`` keyword argument below if you expect that the function will not su
(
func,
*args,
name=None,
token=None,
dtype=None,
chunks=None,
drop_axis=None,
new_axis=None,
enforce_ndim=False,
meta=None,
**kwargs,
)
| 14 | |
| 15 | |
| 16 | def map_blocks( |
| 17 | func, |
| 18 | *args, |
| 19 | name=None, |
| 20 | token=None, |
| 21 | dtype=None, |
| 22 | chunks=None, |
| 23 | drop_axis=None, |
| 24 | new_axis=None, |
| 25 | enforce_ndim=False, |
| 26 | meta=None, |
| 27 | **kwargs, |
| 28 | ): |
| 29 | """Map a function across all blocks of a dask array. |
| 30 | |
| 31 | Note that ``map_blocks`` will attempt to automatically determine the output |
| 32 | array type by calling ``func`` on 0-d versions of the inputs. Please refer to |
| 33 | the ``meta`` keyword argument below if you expect that the function will not |
| 34 | succeed when operating on 0-d arrays. |
| 35 | |
| 36 | Parameters |
| 37 | ---------- |
| 38 | func : callable |
| 39 | Function to apply to every block in the array. |
| 40 | If ``func`` accepts ``block_info=`` or ``block_id=`` |
| 41 | as keyword arguments, these will be passed dictionaries |
| 42 | containing information about input and output chunks/arrays |
| 43 | during computation. See examples for details. |
| 44 | args : dask arrays or other objects |
| 45 | dtype : np.dtype, optional |
| 46 | The ``dtype`` of the output array. It is recommended to provide this. |
| 47 | If not provided, will be inferred by applying the function to a small |
| 48 | set of fake data. |
| 49 | chunks : tuple, optional |
| 50 | Chunk shape of resulting blocks if the function does not preserve |
| 51 | shape. If not provided, the resulting array is assumed to have the same |
| 52 | block structure as the first input array. |
| 53 | drop_axis : number or iterable, optional |
| 54 | Dimensions lost by the function. |
| 55 | new_axis : number or iterable, optional |
| 56 | New dimensions created by the function. Note that these are applied |
| 57 | after ``drop_axis`` (if present). The size of each chunk along this |
| 58 | dimension will be set to 1. Please specify ``chunks`` if the individual |
| 59 | chunks have a different size. |
| 60 | enforce_ndim : bool, default False |
| 61 | Whether to enforce at runtime that the dimensionality of the array |
| 62 | produced by ``func`` actually matches that of the array returned by |
| 63 | ``map_blocks``. |
| 64 | If True, this will raise an error when there is a mismatch. |
| 65 | token : string, optional |
| 66 | The key prefix to use for the output array. If not provided, will be |
| 67 | determined from the function name. |
| 68 | name : string, optional |
| 69 | The key name to use for the output array. Note that this fully |
| 70 | specifies the output key name, and must be unique. If not provided, |
| 71 | will be determined by a hash of the arguments. |
| 72 | meta : array-like, optional |
| 73 | The ``meta`` of the output array, when specified is expected to be an |
no test coverage detected
searching dependent graphs…