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,
)
| 549 | |
| 550 | |
| 551 | def map_blocks( |
| 552 | func, |
| 553 | *args, |
| 554 | name=None, |
| 555 | token=None, |
| 556 | dtype=None, |
| 557 | chunks=None, |
| 558 | drop_axis=None, |
| 559 | new_axis=None, |
| 560 | enforce_ndim=False, |
| 561 | meta=None, |
| 562 | **kwargs, |
| 563 | ): |
| 564 | """Map a function across all blocks of a dask array. |
| 565 | |
| 566 | Note that ``map_blocks`` will attempt to automatically determine the output |
| 567 | array type by calling ``func`` on 0-d versions of the inputs. Please refer to |
| 568 | the ``meta`` keyword argument below if you expect that the function will not |
| 569 | succeed when operating on 0-d arrays. |
| 570 | |
| 571 | Parameters |
| 572 | ---------- |
| 573 | func : callable |
| 574 | Function to apply to every block in the array. |
| 575 | If ``func`` accepts ``block_info=`` or ``block_id=`` |
| 576 | as keyword arguments, these will be passed dictionaries |
| 577 | containing information about input and output chunks/arrays |
| 578 | during computation. See examples for details. |
| 579 | args : dask arrays or other objects |
| 580 | dtype : np.dtype, optional |
| 581 | The ``dtype`` of the output array. It is recommended to provide this. |
| 582 | If not provided, will be inferred by applying the function to a small |
| 583 | set of fake data. |
| 584 | chunks : tuple, optional |
| 585 | Chunk shape of resulting blocks if the function does not preserve |
| 586 | shape. If not provided, the resulting array is assumed to have the same |
| 587 | block structure as the first input array. |
| 588 | drop_axis : number or iterable, optional |
| 589 | Dimensions lost by the function. |
| 590 | new_axis : number or iterable, optional |
| 591 | New dimensions created by the function. Note that these are applied |
| 592 | after ``drop_axis`` (if present). The size of each chunk along this |
| 593 | dimension will be set to 1. Please specify ``chunks`` if the individual |
| 594 | chunks have a different size. |
| 595 | enforce_ndim : bool, default False |
| 596 | Whether to enforce at runtime that the dimensionality of the array |
| 597 | produced by ``func`` actually matches that of the array returned by |
| 598 | ``map_blocks``. |
| 599 | If True, this will raise an error when there is a mismatch. |
| 600 | token : string, optional |
| 601 | The key prefix to use for the output array. If not provided, will be |
| 602 | determined from the function name. |
| 603 | name : string, optional |
| 604 | The key name to use for the output array. Note that this fully |
| 605 | specifies the output key name, and must be unique. If not provided, |
| 606 | will be determined by a hash of the arguments. |
| 607 | meta : array-like, optional |
| 608 | The ``meta`` of the output array, when specified is expected to be an |
no test coverage detected
searching dependent graphs…