JuliaPhysics / JuliaPhysics/Unitful.jl

Type-unstable min/max

Open
#313 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Julia
Stars
675
Forks
124
Avg merge
3h 38m
Merged PRs (30d)
1

Description

For unitless numbers, `min` and `max` promote their arguments to a common type. This does not happen for unitful quantities:
```julia
julia> max(1.0, 2)
2.0

julia> max(1.0u"m", 200u"cm")
200 cm
```
For type-stability and consistency with `Base`, I would prefer if `min`/`max` would promote their arguments for unitful quantities as well.

Edit: According to a comment in the tests, the current behavior is intentional:
https://github.com/PainterQubits/Unitful.jl/blob/09e761b8bb88cfdf7e252096385987f3c141f31e/test/runtests.jl#L476-L478

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the min/max tests in test/runtests.jl around lines 476-478 and read the comment explaining the intentional behavior. Compare the unitful behavior with Julia Base promotion, then determine with maintainers whether the intended result should change; done means an agreed behavior is reflected in the implementation and tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.