Skip to content

Commit 8794613

Browse files
committed
Make dot handle missings
1 parent 27d3931 commit 8794613

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

stdlib/LinearAlgebra/src/generic.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,9 @@ function dot(x, y) # arbitrary iterables
903903
end
904904

905905
dot(x::Number, y::Number) = conj(x) * y
906+
dot(::Any, ::Missing) = missing
907+
dot(::Missing, ::Any) = missing
908+
dot(::Missing, ::Missing) = missing
906909

907910
function dot(x::AbstractArray, y::AbstractArray)
908911
lx = length(x)

stdlib/LinearAlgebra/test/generic.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,14 @@ end
512512
end
513513
end
514514

515+
@testset "dot with missing" begin
516+
x = [5, 6, missing]
517+
y = [missing, 5, 6]
518+
@test ismissing(dot(x, x))
519+
@test ismissing(dot(x, y))
520+
@test ismissing(dot(y, x))
521+
end
522+
515523
@testset "condskeel #34512" begin
516524
A = rand(3, 3)
517525
@test condskeel(A) condskeel(A, [8,8,8])

0 commit comments

Comments
 (0)