Skip to content

Commit

Permalink
Make dot handle missings
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarrasch committed May 10, 2021
1 parent 27d3931 commit 8794613
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
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
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

0 comments on commit 8794613

Please sign in to comment.