-
Notifications
You must be signed in to change notification settings - Fork 0
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
2ufac“°C” gives an incorrect answer #7
Comments
Thanks, this is indeed wrong, and I consider this as a bug to be fixed (so no breaking release). The result of As a bugfix, I will disable handling of affine units and relative temperature I think the approach I am using here does not allow to support these. DynamicQuantities.jl provides another alternative to Unitful which is significantly more sophisticated In the moment it does not support affine quantities either: However, unless with LessUnitful there is a path to an implementation, see this PR over there: |
Thank you for such a detailed reply and for taking this issue seriously. However, as a user, I don't want to have too much trouble, so compared with DynamicQuantities.jl, I'll fall back to unitful.jl+lessunitful.jl for now. |
Oh, wait, I have an idea. You could consider implementing this function in your package, it could solve the problem effectively! unitfactor(a::Unitful.Temperature) = float(ustrip(upreferred(a-0unit(a)))) When |
This is indeed what was happening in the background powered by Unitful. This helps to with An alternative to throwing errors is to document things and and over the responsibility to the user. But I think it is too easy to overlook this issue (as happened with me...) and it is safer to disable handling of °C and °F altogether. |
As the author of SymbolicML/DynamicQuantities.jl#159, I can tell you that affine units are horrible and should not be used directly in mathematical expressions (instead they should be converted to non-affine units as soon as possible). The AffineDimensions in this pull request will interpret scalar multiplication of an affine unit intuitively:
but this is a baked-in behavior of the "Quantity" type. This package will not allow you to do mathematical operations on affine quantities with other units except for subtraction, which explicitly eliminates the offset. This is because it is unclear if "2.0 °C" really means "275.15 K" (an absolute value) or "2.0 K" (a difference). The main reason this pull request exists is to be able to handle affine units without the Unitful.jl extension (which allows you to convert Unitful.jl units to DynamicQuantities). |
2ufac"°C"
gives 548.3 (K), something may be wrong here.Although
ufac"2°C"
gives the correct answer, 275.15, this notation seems not conform to the general paradigm of the package, because for other units, the constants are written first, for example,2ufac"cm"
.Is there any way to fix it?
The text was updated successfully, but these errors were encountered: