-
Notifications
You must be signed in to change notification settings - Fork 111
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
Separate absolute and relative temperature #176
Conversation
Codecov Report
@@ Coverage Diff @@
## master #176 +/- ##
=========================================
- Coverage 97.53% 97.4% -0.14%
=========================================
Files 15 15
Lines 691 694 +3
=========================================
+ Hits 674 676 +2
- Misses 17 18 +1
Continue to review full report at Codecov.
|
Here's one issue: julia> mean([1abs°C, 2abs°C])
ERROR: DimensionError: 1 abs°C and 2 abs°C are not dimensionally compatible.
Stacktrace:
[1] +(::Quantity{Int64,Unitful.Dimensions{(Unitful.Dimension{:AbsTemperature}(1. We can fix it manually, but it's a bit worrying. |
(A nobody giving his opinion) I wouldn't pay much attention to the I understand the appeal to make the new weirdos in town (units with offsets) bear the prefix. But I think that it would introduce less silent mistakes to make the traditional names (°C, °F, K) default to the absolute ones which IIUC would error more often when misused (you can't add them, multiply, etc). As is, |
@RuiRojo Nobody's a nobody, thanks for your interest! Not sure what to think yet regarding the unit names. @cstjean Thanks for the PR. I think I agree with the general premise (still open to further discussion of unit names) but I don't think there should be a new dimension defined. The dimension of temperature ought to be the same regardless of absolute / relative scales. I imagine you were trying for a minimally invasive mechanism to identify absolute / relative scale from the type, but rather than compromise on dimensional correctness I think we could generalize the |
Thank you for the comments. I agree that a general solution would be better.
Conceptually, I agree, but pragmatically, I can define functions with dimensions in the signature, like
Sounds good. The current PR is good enough for our purposes, so I don't know when/if I'll have time to push this further. If anyone wants to take a shot at this, please do. |
This is exciting! I'm not even a Julia user yet, but it's great to see how the language allows library writers to offer tools that do the right thing™, without sacrificing expressiveness. And of course, kudos to you guys! Now if only arrays would start at zero... |
Closed in favor of #177, discussion can continue there. |
Following the discussion in #137, I separated absolute and relative temperature units, similar to @burnpanck's suggestion. It works well so far. Notable new test cases:
This PR is a proposal for discussion. If the general approach is acceptable, then we might find a less ugly name than
35abs°C
. And of course: documentation.Regarding binary arithmetic on absolute temperatures, we can either disallow promotion of two absolute temperatures in general, and explicitly allow some operations (
-, ==, ...?
) or allow all operations by default and disallow some (+, *, /, ...?
) by throwing an exception. I did the latter in this PR, but I also tested the former and it works too.Fix #137 and #72