Skip to content

LinearAlgebra.dot fails with Vector{Union{Float, Missing}} #844

@Datseris

Description

@Datseris

MWE:

julia> using LinearAlgebra

julia> x = [5, 6, missing];

julia> w = [1, 2, 3];

julia> dot(x, w)
ERROR: MethodError: no method matching iterate(::Missing)
Closest candidates are:
  iterate(::Union{LinRange, StepRangeLen}) at range.jl:664
  iterate(::Union{LinRange, StepRangeLen}, ::Int64) at range.jl:664
  iterate(::T) where T<:Union{Base.KeySet{var"#s79", var"#s78"} where {var"#s79", var"#s78"<:Dict}, Base.ValueIterator{var"#s77"} where var"#s77"<:Dict} at dict.jl:693
  ...
Stacktrace:
   [1]  internal
     @ LinearAlgebra
   [2] dot(x::Vector{Union{Missing, Int64}}, y::Vector{Int64})
     @ LinearAlgebra C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\generic.jl:916
Use `err` to retrieve the full stack trace.

I would have assumed that the dot should yield missing.

For reference, I came across this using StatsBase.mean(x, weights(w)).

Metadata

Metadata

Assignees

No one assigned

    Labels

    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