Skip to content
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

degree_Celsius to_compact raises DimensionalityError (Pint 0.23) #2005

Open
xolodho opened this issue Jun 5, 2024 · 1 comment
Open

degree_Celsius to_compact raises DimensionalityError (Pint 0.23) #2005

xolodho opened this issue Jun 5, 2024 · 1 comment

Comments

@xolodho
Copy link

xolodho commented Jun 5, 2024

Calling to_compact on a celsius magnitude of absolute value smaller than
1 doesn't work properly.

For example, the following throws a pint.errors.DimensionalityError
exception:

  from pint import Quantity
  Quantity(0.1, "degree_Celsius").to_compact()

However, if right afterwards you re-run the to_compact line again, then
it does not throw exception, but instead returns

 <Quantity(273250.0, 'millidegree_Celsius')>,

which is numerically incorrect (that's milliKelvin?).

So calling to_compact for 0.1 degrees celsius either raises exception
(the first time), or returns an incorrect answer (the second time). It
would seem this bug doesn't happen if the magnitude is ≥1 in absolute
value, e.g. 1 and -2.5 and 5.8 are all ok, but 0.1 and 0.999
fail.

using Pint 0.23 installed from pip on Linux.

@andrewgsavage
Copy link
Collaborator

Interesting. This behaviour may be changed on master and the next version. There's a release candidate out you can install with pip install pint --pre

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants