From 6f61dc313b415b0c905cb93d28c2530e0d80f991 Mon Sep 17 00:00:00 2001 From: Tianyi Pu <44583944+putianyi889@users.noreply.github.com> Date: Fri, 30 Aug 2024 03:22:07 +0800 Subject: [PATCH] fix #178 (#343) * fix #178 * Update FillArraysSparseArraysExt.jl * try to fix --------- Co-authored-by: Sheehan Olver --- ext/FillArraysSparseArraysExt.jl | 14 ++++++++++++-- test/runtests.jl | 11 ++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ext/FillArraysSparseArraysExt.jl b/ext/FillArraysSparseArraysExt.jl index a33b89d8..6021296b 100644 --- a/ext/FillArraysSparseArraysExt.jl +++ b/ext/FillArraysSparseArraysExt.jl @@ -1,12 +1,14 @@ module FillArraysSparseArraysExt using SparseArrays -using FillArrays -using FillArrays: RectDiagonalFill, RectOrDiagonalFill, ZerosVector, ZerosMatrix, getindex_value +using SparseArrays: SparseVectorUnion import Base: convert, kron +using FillArrays +using FillArrays: RectDiagonalFill, RectOrDiagonalFill, ZerosVector, ZerosMatrix, getindex_value, AbstractFillVector, _fill_dot # Specifying the full namespace is necessary because of https://github.com/JuliaLang/julia/issues/48533 # See https://github.com/JuliaStats/LogExpFunctions.jl/pull/63 using FillArrays.LinearAlgebra +import LinearAlgebra: dot, kron, I ################## ## Sparse arrays @@ -58,4 +60,12 @@ end # TODO: remove in v2.0 @deprecate kron(E1::RectDiagonalFill, E2::RectDiagonalFill) kron(sparse(E1), sparse(E2)) +# Ambiguity. see #178 +if VERSION >= v"1.8" + dot(x::AbstractFillVector, y::SparseVectorUnion) = _fill_dot(x, y) +else + dot(x::AbstractFillVector{<:Number}, y::SparseVectorUnion{<:Number}) = _fill_dot(x, y) +end + + end # module diff --git a/test/runtests.jl b/test/runtests.jl index 41c518cd..b3474f05 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1438,9 +1438,14 @@ end @test axes(E .+ E) === axes(E) end -@testset "Issue #31" begin - @test convert(SparseMatrixCSC{Float64,Int64}, Zeros{Float64}(3, 3)) == spzeros(3, 3) - @test sparse(Zeros(4, 2)) == spzeros(4, 2) +@testset "Issues" begin + @testset "#31" begin + @test convert(SparseMatrixCSC{Float64,Int64}, Zeros{Float64}(3, 3)) == spzeros(3, 3) + @test sparse(Zeros(4, 2)) == spzeros(4, 2) + end + @testset "#178" begin + @test Zeros(10)'*spzeros(10) == 0 + end end @testset "Adjoint/Transpose/permutedims" begin