Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make dot handle missings #40769

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions stdlib/LinearAlgebra/src/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,9 @@ function dot(x, y) # arbitrary iterables
end

dot(x::Number, y::Number) = conj(x) * y
dot(::Any, ::Missing) = missing
dkarrasch marked this conversation as resolved.
Show resolved Hide resolved
dot(::Missing, ::Any) = missing
dot(::Missing, ::Missing) = missing

function dot(x::AbstractArray, y::AbstractArray)
lx = length(x)
Expand Down
8 changes: 8 additions & 0 deletions stdlib/LinearAlgebra/test/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,14 @@ end
end
end

@testset "dot with missing" begin
x = [5, 6, missing]
y = [missing, 5, 6]
@test ismissing(dot(x, x))
@test ismissing(dot(x, y))
@test ismissing(dot(y, x))
end

@testset "condskeel #34512" begin
A = rand(3, 3)
@test condskeel(A) ≈ condskeel(A, [8,8,8])
Expand Down