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

cast units to `str` before applying any other preprocessor #498

Closed keewis closed 5 months ago

keewis commented 5 months ago

The idea is to accept integer units of 1 for dimensionless, which is explicitly allowed by the CF conventions (we could, however, pass through objects that are not integers unmodified).

Note that pint itself doesn't really like the idea of integer units, so this will only work with ureg.parse_units(1): ureg.Quantity(1, 1) will raise before any preprocessor is called.

codecov[bot] commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (a9cebee) 85.78% compared to head (3ee6b89) 85.79%.

:exclamation: Current head 3ee6b89 differs from pull request most recent head 997ea4b. Consider uploading reports for the commit 997ea4b to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #498 +/- ## ======================================= Coverage 85.78% 85.79% ======================================= Files 13 13 Lines 2364 2365 +1 Branches 183 183 ======================================= + Hits 2028 2029 +1 Misses 303 303 Partials 33 33 ``` | [Flag](https://app.codecov.io/gh/xarray-contrib/cf-xarray/pull/498/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xarray-contrib) | Coverage Δ | | |---|---|---| | [mypy](https://app.codecov.io/gh/xarray-contrib/cf-xarray/pull/498/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xarray-contrib) | `38.55% <100.00%> (+0.02%)` | :arrow_up: | | [unittests](https://app.codecov.io/gh/xarray-contrib/cf-xarray/pull/498/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xarray-contrib) | `93.99% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xarray-contrib#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.