Skip to content

Questions with map_blocks and apply_ufunc #6370

Answered by dcherian
philippemiron asked this question in Q&A
Discussion options

You must be logged in to vote

why do we have to use .data here?

.data pulls out the underlying dask array; .data.map_blocks calls dask.array.map_blocks.

Functions passed to map_blocks() have to either return a xr.DataArray or an np.array, is that correct?

For xarray.map_blocks must return either a Dataset or a DataArray, For dask.array.map_blocks must return a numpy array.


Your example with dask="parallelized" cannot be right. It raises ValueError: axes don't match array on compute and should never have worked AFAICT (#6372)


For the solution, this operation is too complicated for dask="parallelized" so we use dask="allowed". This means your function must know how to handle dask arrays.
1. The function itself loo…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@philippemiron
Comment options

@dcherian
Comment options

Answer selected by philippemiron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants