Skip to content

Commit da0adc3

Browse files
keewisdcherian
andauthored
mention map_blocks in the docstring of apply_ufunc (#5011)
Co-authored-by: Deepak Cherian <[email protected]>
1 parent 50d97e9 commit da0adc3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

xarray/core/computation.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,14 @@ def apply_ufunc(
923923
Single value or tuple of Dataset, DataArray, Variable, dask.array.Array or
924924
numpy.ndarray, the first type on that list to appear on an input.
925925
926+
Notes
927+
-----
928+
This function is designed for the more common case where ``func`` can work on numpy
929+
arrays. If ``func`` needs to manipulate a whole xarray object subset to each block
930+
it is possible to use :py:func:`xarray.map_blocks`.
931+
932+
Note that due to the overhead ``map_blocks`` is considerably slower than ``apply_ufunc``.
933+
926934
Examples
927935
--------
928936
Calculate the vector magnitude of two arguments:
@@ -1015,6 +1023,8 @@ def earth_mover_distance(first_samples,
10151023
numpy.broadcast_arrays
10161024
numba.vectorize
10171025
numba.guvectorize
1026+
dask.array.apply_gufunc
1027+
xarray.map_blocks
10181028
10191029
References
10201030
----------

0 commit comments

Comments
 (0)