pint-xarray icon indicating copy to clipboard operation
pint-xarray copied to clipboard

Draft: add wraps_ufunc decorator

Open tbody-cfs opened this issue 2 years ago • 3 comments

  • [ ] Closes #xxxx
  • [ ] Tests added
  • [ ] Passes pre-commit run --all-files
  • [ ] User visible changes (including notable bug fixes) are documented in whats-new.rst
  • [ ] New functions/methods are listed in api.rst

tbody-cfs avatar Jan 31 '23 19:01 tbody-cfs

Hi, Thanks for making a great project — I've always wanted xarray to support pint units. Dropping here in case it's useful — I often need to use functions written for float or numpy arrays. To handle units I'd use ureg.wraps and to handle xarrays I'd use apply_ufunc. I've looked at the inner workings of ureg.wraps and tried to approximate it, adding in apply_ufunc.

If this seems helpful, I could tidy it up. If you've got a better way of doing this, I'd be very happy to hear :)

tbody-cfs avatar Jan 31 '23 19:01 tbody-cfs

This might be a duplicate of https://github.com/xarray-contrib/pint-xarray/pull/143.

tbody-cfs avatar Jan 31 '23 19:01 tbody-cfs

thanks for the PR and sorry for the delay, @tbody-cfs. This is definitely something on our roadmap, but unfortunately I didn't have too much time to work on this in the past few months.

Indeed, this PR is a duplicate of #143, which as an initial version should be very close. However, I fear we didn't try using too much, yet, so the API might not be as useful as we thought it would be (and of course there might be bugs). If you want to help moving that forward, I think it would be great to just experiment with expects and report your findings in #143 (and post any questions / feedback you might have).

keewis avatar Feb 14 '23 22:02 keewis