xarray-contrib / cf-xarray

an accessor for xarray objects that interprets CF attributes
https://cf-xarray.readthedocs.io/
Apache License 2.0
152 stars 39 forks source link

Rewrite unit formatter for pint 0.24 and earlier #523

Closed aulemahal closed 2 days ago

aulemahal commented 1 week ago

Fixes #522 and hgrecco/pint#2024.

I tested this with pint 0.24.1 and 0.23. I also did a very minimal test with pint 0.22 down to 0.12. This seems to support pint >= 0.18, like the previous version did.

With pint < 0.24 the only difference this makes is that dimensionless units are returned as "" with {u:cf} and {u:~cf}, where as the previous version returned "dimensionless" for {u:cf}.

dcherian commented 5 days ago

Failure is real.

keewis commented 5 days ago

I've been a bit away from pint, so I'll have to first look into how it changed in the most recent version before giving any thorough reviews, but at a quick glance this looks fine.

dcherian commented 5 days ago

but at a quick glance this looks fine.

Thanks! no need for a thorough review.