Open cstjean opened 5 years ago
The answer should be missing
?
It should be the same as
julia> sum([1 0 missing], dims=2)
1×1 Array{Union{Missing, Int64},2}:
missing
Without dims it already works:
julia> sum([true false missing])
missing
This is due to this line: https://github.com/JuliaLang/julia/blob/8d4f6d24c0fa87509fcf40788ca2c83cdfecd9af/base/reducedim.jl#L119
In https://github.com/JuliaLang/julia/pull/28089 I fixed reduction over Array{Union{Int,Missing}}
, but that fix was not enough to cover types for which +
/add_sum
returns a different type. Actually even for Int
it's not really a great strategy.
The only really correct solution would be to use the same approach as map
when dims
isn't specified: start with an array based on the type of the first two values, and widen it when encountering values of a new type. But that's going to be relatively tricky to write.
On 1.1 and 1.2RC1: