Define minimum and maximum of empty arrays to return typemax and typemin#52004
Define minimum and maximum of empty arrays to return typemax and typemin#52004
Conversation
b87fdeb to
6ca85cd
Compare
|
Looks like this still runs into this SparseArray problem: |
|
OK, I have two good examples of why I don't like these behaviors. With this patch: julia> minimum(Union{Missing,Int}[])
ERROR: MethodError: no method matching typemax(::Type{Union{Missing, Int64}})
julia> minimum(abs, Union{Missing,Int}[])
9223372036854775807
julia> maximum(Union{Missing,Int}[])
ERROR: MethodError: no method matching typemin(::Type{Union{Missing, Int64}})
julia> maximum(abs, Union{Missing,Int}[])
0While I think it makes some sense that It also just doesn't seem like this is necessarily true in the abstract — for example: julia> maximum(abs, Int8[])
0
julia> maximum(abs, Int8[-128]) # But there _does exist_ a lesser least element!
-128That last example doesn't even require this patch — that's the current behavior of Julia. Still bad, though, and representative of what this patch wants to do more of. |
😬 that's unfortunate. maybe that can be fixed in your PR which is already slightly breaking? after all (slightly breaking ---> slightly more breaking) is a much smaller jump than (not breaking ---> slightly breaking) |
Relands #29919