Skip to content
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

Kelvin and °C should not be comparable? #521

Open
cstjean opened this issue Feb 17, 2022 · 2 comments
Open

Kelvin and °C should not be comparable? #521

cstjean opened this issue Feb 17, 2022 · 2 comments
Labels
affine affine quantities like °C, °F, …

Comments

@cstjean
Copy link
Contributor

cstjean commented Feb 17, 2022

Currently,

julia> 5K - 5°C
ERROR: AffineError: an invalid operation was attempted with affine quantities: 5 K - 5 °C

which is great because it's ambiguous, but

julia> 10°C - 5°C > 2°C
false

This is clearly wrong for anyone who doesn't know about Unitful quirks, and it just bit one of my colleagues. In this case, 10°C - 5°C becomes 5K, which is considered less than 2°C because 2°C == 275 K.

Thus, Kelvin and °C comparisons should be an AffineError.

@lukebemish
Copy link
Contributor

One possible issue here is that there are times you would want to compare values in Kelvin and °C - for instance, if you've got a series of inputs to something in a mix of both, or simply if you've got values in both. It might actually be worth rethinking how affine units are thought of in general, actually - I would say that a difference between two affine values, say 200 K - 150 K, should probably not be comparable to an affine value on its own, but affine values in differing units, but the same dimension, should still be comparable, though I'm not sure if there's any good way to implement this.

@sostock sostock added the affine affine quantities like °C, °F, … label Dec 7, 2022
@cstjean
Copy link
Contributor Author

cstjean commented May 20, 2024

I would say that a difference between two affine values, say 200 K - 150 K, should probably not be comparable to an affine value on its own,

I'm sympathetic to that, it's similar to the 4D matrix affine transformation in 3D rendering pipelines. #176 was my attempt as this, but it was superseded by Andrew's PR which didn't implement that distinction directly (but which is admittedly a lot more elegant than my PR)

See also discussion in #137

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affine affine quantities like °C, °F, …
Projects
None yet
Development

No branches or pull requests

3 participants