Skip to content

sum(::Matrix{Union{Bool, Missing}}) fails with dims argument #32366

@cstjean

Description

@cstjean

On 1.1 and 1.2RC1:

julia> sum([true false missing], dims=2)
ERROR: MethodError: Cannot `convert` an object of type Missing to an object of type Int64
Closest candidates are:
  convert(::Type{T<:Number}, ::T<:Number) where T<:Number at number.jl:6
  convert(::Type{T<:Number}, ::Number) where T<:Number at number.jl:7
  convert(::Type{T<:Integer}, ::Ptr) where T<:Integer at pointer.jl:23
  ...
Stacktrace:
 [1] setindex! at ./array.jl:768 [inlined]
 [2] setindex! at ./multidimensional.jl:488 [inlined]
 [3] _mapreducedim!(::typeof(identity), ::typeof(Base.add_sum), ::Array{Int64,2}, ::Array{Union{Missing, Bool},2}) at ./reducedim.jl:261
 [4] mapreducedim!(::Function, ::Function, ::Array{Int64,2}, ::Array{Union{Missing, Bool},2}) at ./reducedim.jl:274
 [5] _mapreduce_dim(::Function, ::Function, ::NamedTuple{(),Tuple{}}, ::Array{Union{Missing, Bool},2}, ::Int64) at ./reducedim.jl:317
 [6] #mapreduce#555 at ./reducedim.jl:307 [inlined]
 [7] #mapreduce at ./none:0 [inlined]
 [8] _sum at ./reducedim.jl:679 [inlined]
 [9] _sum at ./reducedim.jl:678 [inlined]
 [10] #sum#558 at ./reducedim.jl:652 [inlined]
 [11] (::getfield(Base, Symbol("#kw##sum")))(::NamedTuple{(:dims,),Tuple{Int64}}, ::typeof(sum), ::Array{Union{Missing, Bool},2}) at ./none:0
 [12] top-level scope at REPL[1]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrays[a, r, r, a, y, s]foldsum, maximum, reduce, foldl, etc.missing dataBase.missing and related functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions