-
Notifications
You must be signed in to change notification settings - Fork 12
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
Integration with Uncertainties #3
Comments
Right now, Pint does not simultaneously support NumPy and Uncertainties, so this integration would likely have to be on hold until they would become mutually supported. xref pydata/xarray#3509 |
@jthielen Do you happen to know if there are any plans to support integrating both packages at once? |
As far as I'm aware, it's a desired feature but has no roadmap or timeline to implementation. Though, I'd encourage you to ask directly on the Pint issue, as the Pint maintainers themselves may have a better idea! |
Thanks for your response. Somehow I didn't notice that this issue was actually on a different repo! |
With regards to uncertainties, I think one difficulty with the existing uncertainties package is that you have to hand-write the propagation rules for each operation, which is definitely not feasible for the entire numpy library. If you used an auto-differentiation library like JAX, you could imagine trying to have that implement Probably the best way to do it would be to re-implement it in xarray. Would there be any interest in this? I would definitely be interesting in contributing towards getting something like this to work. |
@varchasgopalaswamy if you can get uncertainty support working in xarray in a general and interoperable way, people would love that! I would expect it to be a pretty big project though.
Can you expand on what you mean by this? Making uncertainties work in a way that doesn't prevent you from using xarray as your top-level object, and also using different array types underneath (e.g. dask, cupy), would be critical for widespread adoption. There are also some discussions about potentially wrapping Jax in xarray ( I can find links if you want). |
Agreed, I don't expect it to be easy - but I would find it useful for my research. We're thinking of adopting xarray throughout our code, which requires support for uncertainty propagation, so I have a vested interest in getting this to work!
I am still new to xarray and I need to get more familiar with the data model and terminology, so I might not be saying this right. Looking through this repo, it looks like how pint integration is being done is by either converting the value stored in a |
This is how every cool feature gets made :)
Xarray objects are wrappers of numpy arrays, or of arrays that can be treated as if they were numpy arrays (so-called "duck-typed arrays"). Xarray expects that the wrapped array exposes certain methods and attributes (e.g. Xarray organises and aligns the wrapped data, but the actual computation is always performed by the underlying array type. So So in the case of pint, xarray is wrapping a
Basically yes, but if you start with a Dataset with quantified values, the other steps are handled automatically by xarray delegating to the wrapped EDIT with some links: This issue might interest you - it's about wrapping ragged-length arrays with xarray, but it Comment about JAX in xarray pydata/xarray#3232 (comment) Project board for xarray wrapping all the arrays |
It would be absolutely great to be able to propagate unit-aware arrays with uncertainties through xarray, but it's unclear to me to what extent pint is currently integrated with the Uncertainties package.
I also haven't thought much about whether this would present any additional challenges on the xarray side.
The text was updated successfully, but these errors were encountered: