-
Notifications
You must be signed in to change notification settings - Fork 465
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
Wrong calculation when using temperature prefixes #1381
Comments
It seems millidegree_Celsius is not identified as offset units in the convert stage hence the value does not make sense afterwards. I'll investigate |
Any progress so far on this bug? |
The issue has been identified but the implementation is tricky with the current implementation: Lines 1529 to 1550 in c99ed1f
Here the conversion for offset untis is handled like so:
In the case of prefixed units:
calculation does output the wrong value, for those steps
I'll probably end up with a fix for only those prefixed temperature units. Thoughts @hgrecco? I find it difficult to work with UnitDefinition, UnitsContainer there |
At the very beginning of Pint (before offset units were implemented) there was a proposal to to write a special converter for ocassions in which prefix was removed, added or change. This was dropped as unnecesary in that case and would have helped here. However, I do think there is a deeper thing to discuss. IMHO si-prefixing offset units is not a good practice. It is ok to express an interval (in which case the temperature becomes a multiplicative unit anyway). And is is kind of ok to write a value, but we should be careful when operating (converting, arithmetics, etc) with this value. |
I also thought a bit about this: mDegC is the same as 1e-3 * degC which is a multiplication that is forbidden by default. So to be consistent pint should in my opinion raise errors for
I would vote for raising errors even with |
Moving this to #1754 |
I'm doing following conversion:
output:
293150.0 millidegree_Celsius
It seems like prefixes for degree Celsius are not handled correctly. The result should be 20000 millidegree_Celsius.
Looks like it changes the unit to Kelvin internally.
It this a known issue? Is there a workaround for my use case?
The text was updated successfully, but these errors were encountered: