-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Error comparing temperature units with offset #3134
Comments
Thanks for bringing up this bug. I had a short look around, and this looks like a serious issue: there are quite some places where the Does that make sense @gwhitney ? |
I mean it's all related to the contrast between absolute temperatures and differences between two temperatures and losing track of which a given temperature unit entity is supposed to be. All these things should be moved to a separate Unit class and solved there. I am at a bit of a loss of how to solve then while Unit is integrated in mathjs. I am in fact getting to be sorry I meddled in temperature units at all -- I fear I made things worse :-( |
Yes indeed. It is tricky stuff. Do you think that implementing a utility method like |
Well if it were up to me I would have totally distinct units for temp differences and absolute temperatures. But thinking back to earlier issues/discussions, that didn't seem to be the consensus solution. But short of that, I don't understand what to do when asked to compare 200 degK and 300 degK -- if one is a temperature difference and the other a specific temperature, the comparison doesn't actually make sense as far as I can see... |
If I recall, the suggestion was that F and C should only be used for specific temperatures and that taking a difference would always end up with R or K, where the contrast between temp differences and specific temps is less of an issue b/c of existence of absolute zero. (So arithmetic with degC would auto convert to degK, for example.) Then the current .value() should work just like the .absValue() you want -- that's how it was supposed to work originally, and you wouldn't need a new method. So if I had to try to fix this, I would read all the temperature unit issues, and if they all seemed consistent with that plan, I'd head that way. |
I don't remember all the details of earlier discussions either 😅. Originally, the Let me try to summarize the different topics to see where we stand (the "desired behavior" is now under discussion, I filled in what makes most sense to me):
To fix the "value property" issue we can go two ways I think:
Option (1) is quite straightforward, but I'm not sure how much work is involved in option (2). Any idea? |
It's not possible to fill in the table without deciding what entities you want to allow to be temperature deltas and what ones are only allowed to be specific temperatures. If I am recalling, one proposal was that celsius and fahrenheit may only be used for specific temperatures, whereas we would allow Kelvin and Rankine for temp differences. In that case, the desired values column would become:
I think if you look back at other issues, they would work fine with this change. I'd be comfortable going in this direction if we have to fix this within mathjs, i.e. before things are farmed out to independent Unit class. |
I agree with the proposal Glen is mentioning and is consistent with other software I know. Where it's the user's responsibility to do temperature differences with Kelvin and Rankine.
Maybe there is a mathjs way of solving this problem but it seems complicated. |
It makes sense indeed to throw an error when trying to add two temperatures like Should we maybe also be more restrictive with subtraction, and not allow Thanks Glen, It would be great if you could work out a solution for this! |
I see three ways to go with subtraction:
As implied by my values above, I prefer 1, because addition is naturally restricted to case (3) -- you could write 10 degC + (-5 K) -- so you get more well-defined behavior by pushing subtraction toward (1). Note that in none of these interpretations would I advocate 10K - 5degC to be interpreted as moving -5degC by 10K, since degC should not be used for a temperature offset, so the interpretation of subtraction as applying the negation of a temperature offset is not available. So all that is left in this case is interpretation as the temperature distance between two specific temperatures, whichever of (1)-(3) above is adopted. |
Thanks for your explanation, your option (1) indeed makes sense, calculating it as a temperature difference. If that still results in confusion, we could look into option (2) and make it more restrictive, but no need for it now I think. |
Hi,
In versiones newer than 11.4.1 the comparison of temperatures is incorrect between some temperature units when an offset is involved.
This was discussed in #2518 but this might need to be a separate issue.
The text was updated successfully, but these errors were encountered: