You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some time ago, cf-xarray implemented a CF-compliant unit formatter using pint.register_unit_format. It works well except for dimensionless quantities. The current code for format_unit hardcodes what happens with dimensionless units. It's either "" if there was a ~ flag or:
Which makes the custom formatter unable to modify the behaviour. In our case here, the CF version would be "" (and sometimes "1" when not attached to a magnitude).
Could we simply remove the code I linked? Pass the container to the formatting function, as with other units?
Tagging @dcherian that might be interested in this issue.
The text was updated successfully, but these errors were encountered:
As far as I understand it, % is some kind of unit modifier? If that's correct, I think we should try to treat it the same way as the other modifiers (and document it in the "string formatting" guide). That way, #1448 would allow you to customize its behavior.
Hi!
Some time ago,
cf-xarray
implemented a CF-compliant unit formatter usingpint.register_unit_format
. It works well except for dimensionless quantities. The current code forformat_unit
hardcodes what happens with dimensionless units. It's either "" if there was a~
flag or:pint/pint/formatting.py
Lines 397 to 401 in 7394cd9
Which makes the custom formatter unable to modify the behaviour. In our case here, the CF version would be "" (and sometimes "1" when not attached to a magnitude).
Could we simply remove the code I linked? Pass the container to the formatting function, as with other units?
Tagging @dcherian that might be interested in this issue.
The text was updated successfully, but these errors were encountered: