fix: added branch for value_in to handle Celsius#108
Merged
Conversation
Added branching logic to handle conversion to `Celsius` in the `value_in` method of `PySIObject`. `Celsius` now a valid input for the `unit` argument.
Contributor
|
Thanks for the fix, I didn't foresee this initially. While we're at it, can you also add the |
Contributor
|
Sorry, maybe I was unclear. What I meant was basically impl Angle {
...
fn value_in(&self, unit: &Self) -> f64 {...}Just to avoid confusion about the |
`Angle` now mirrors `SIObject` with its own `value_in` method.
Contributor
Author
|
Yes sorry I deleted my message |
Contributor
Author
|
I notice what you meant. Havent read up on Angle when I implemented the fix. Realised what you meant. Added the mirror. Hope this works! |
prehner
approved these changes
Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added branching logic to handle conversion to
Celsiusin thevalue_inmethod ofPySIObject.Celsiusnow a valid input for theunitargument.Honestly suprised I haven't caught this one given that I worked in low carbon heating. But the current implementation of
value_inthat I suggested few days ago does not take into account the seperate implementation ofCelsiussoresults.value_in(si_units.Celsius)would return a TypeError becauseCelsiusis not an instance ofSIObject.The best way I can think of to fix this is to add a branch to handle
Celsiusas you did with__truediv__.Think the overhead this fix add should be negligible. Not sure what you guys think?