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

middle() on affine units #629

Open
jariji opened this issue Mar 17, 2023 · 4 comments
Open

middle() on affine units #629

jariji opened this issue Mar 17, 2023 · 4 comments
Labels
affine affine quantities like °C, °F, …

Comments

@jariji
Copy link

jariji commented Mar 17, 2023

Should I be able to do this?

using Statistics
julia> middle(33°F, 35°F)
ERROR: AffineError: an invalid operation was attempted with affine units: °F
@cstjean
Copy link
Contributor

cstjean commented Mar 17, 2023

Yeah, several similar methods are probably necessary #200

@jariji
Copy link
Author

jariji commented Mar 17, 2023

I was thinking the solution was to just redefine Statistics.middle(x,y) = (x-y)/2 + y but

julia> (33°F - 32°F)/2  + 32°F
273.4277777777778 K

produces a result in Kelvin instead of Fahrenheit, which I didn't expect.

@cstjean
Copy link
Contributor

cstjean commented Mar 17, 2023

We're not super happy with how quickly temperature manipulation becomes all-Kelvin, either. But you can convert it back to Celsius, of course.

@jariji
Copy link
Author

jariji commented Mar 18, 2023

Related JuliaStats/Statistics.jl#47

@sostock sostock added the affine affine quantities like °C, °F, … label Mar 22, 2023
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