-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UserWarning when wrapping pint & dask arrays together #5559
Comments
Is it correct that xarray ends up calling import dask.array as da
da = xr.DataArray([1,2,3], attrs={'units': 'metres'})
chunked = da.chunk(1).pint.quantify()
da.mean(chunked.variable._data) Also, the Dask warning If so, I think this gets into a thorny issue with duck array handling in Dask. It was decided in dask/dask#6393 that deliberately calling Dask array operations like If this all checks out, I believe this becomes a Dask issue to improve upcast type/duck Dask array handling. |
Yes that's correct. See xarray/xarray/core/duck_array_ops.py Lines 49 to 51 in c472f8a
It may be time to update this method since we now depend on a minimum numpy version that supports NEP-18. cc @shoyer EDIT: You get there from xarray/xarray/core/duck_array_ops.py Line 347 in c472f8a
|
So this is actually an xarray problem not a dask/pint problem? And the solution would be to just call the method on the duck array without any kind of type checking first? |
Or |
With
pint-xarray
you can create a chunked, unit-aware xarray object, but calling a calculation method and then computing doesn't appear to behave as hoped.So far this is fine, but if we try to take a mean before computing we get
This is not correct: as well as the UserWarning, the return value of compute is a dask array, meaning we need to compute a second time to actually get the answer:
If we try chunking the other way (
chunked = da.pint.quantify().pint.chunk(1)
) then we get all the same results.xref xarray-contrib/pint-xarray#116 and #4972 @keewis
The text was updated successfully, but these errors were encountered: