xr.map_blocks
vs dask.array.map_blocks
wrapping numpy
function
#6482
-
issue arised in zarr-developers/numcodecs#299 I want to apply a numpy function from numcodecs.bitround import BitRound
def _np_bitround(data, keepbits):
"""Bitround for Arrays."""
codec = BitRound(keepbits=keepbits)
data = data.copy() # otherwise overwrites the input
encoded = codec.encode(data)
return codec.decode(data) to My observations:
but works for So there might be something in Additional context: https://stackoverflow.com/questions/51736172/whats-the-difference-between-dask-parallelized-and-dask-allowed-in-xarrays-app |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
The underlying function you're using is designed to work with numpy arrays. Notice |
Beta Was this translation helpful? Give feedback.
Please see https://docs.xarray.dev/en/stable/user-guide/dask.html#automatic-parallelization-with-apply-ufunc-and-map-blocks
xr.map_blocks
does not wrapdask.array.map_blocks
.xr.apply_ufunc(..., dask="parallelized")
wrapsdask.array.apply_gufunc
which ends up being equivalent todask.array.map_blocks
.The underlying function you're using is designed to work with numpy arrays. Notice
np.array(mem)