diff --git a/Project.toml b/Project.toml index 0362e1a..109f579 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "LowRankMatrices" uuid = "e65ccdef-c354-471a-8090-89bec1c20ec3" authors = ["Jishnu Bhattacharya and contributors"] -version = "1.0.0" +version = "1.0.1" [deps] FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" @@ -14,12 +14,16 @@ FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" LowRankMatricesFillArraysExt = "FillArrays" [compat] +Aqua = "0.8" FillArrays = "0.6, 0.7, 0.8, 0.9, 0.10, 0.11, 0.12, 0.13, 1" +LinearAlgebra = "<0.0.1, 1" +Test = "<0.0.1, 1" julia = "1" [extras] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test", "FillArrays"] +test = ["Aqua", "Test", "FillArrays"] diff --git a/src/lowrankmatrix.jl b/src/lowrankmatrix.jl index f610ab2..b9e817a 100644 --- a/src/lowrankmatrix.jl +++ b/src/lowrankmatrix.jl @@ -68,10 +68,11 @@ function refactorsvd!(U::AbstractMatrix{S}, Σ::AbstractVector{T}, V::AbstractMa r end -for MAT in (:LowRankMatrix, :AbstractMatrix, :AbstractArray) - @eval convert(::Type{$MAT{T}}, L::LowRankMatrix) where {T} = - LowRankMatrix(convert(Matrix{T}, L.U), convert(Matrix{T}, L.V)) +function convert(::Type{LowRankMatrix{T}}, L::LowRankMatrix) where {T} + L isa LowRankMatrix{T} && return L + LowRankMatrix(convert(Matrix{T}, L.U), convert(Matrix{T}, L.V)) end + convert(::Type{Matrix{T}}, L::LowRankMatrix) where {T} = convert(Matrix{T}, Matrix(L)) promote_rule(::Type{LowRankMatrix{T}}, ::Type{LowRankMatrix{V}}) where {T,V} = LowRankMatrix{promote_type(T,V)} promote_rule(::Type{LowRankMatrix{T}}, ::Type{Matrix{V}}) where {T,V} = Matrix{promote_type(T,V)} diff --git a/test/aqua.jl b/test/aqua.jl new file mode 100644 index 0000000..b86aa0c --- /dev/null +++ b/test/aqua.jl @@ -0,0 +1,7 @@ +using Aqua +using LowRankMatrices +using Test + +@testset "Project quality" begin + Aqua.test_all(LowRankMatrices) +end diff --git a/test/runtests.jl b/test/runtests.jl index 205258d..f112b8e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,6 +3,10 @@ using Test using LinearAlgebra using FillArrays +if VERSION >= v"1.10" + include("aqua.jl") +end + @testset "Constructors" begin @test Matrix(LowRankMatrix(Zeros(10,5))) == zeros(10,5) @@ -45,6 +49,18 @@ using FillArrays end +@testset "convert" begin + L = LowRankMatrix([1,2], [1,2]) + Lf = convert(LowRankMatrix{Float64}, L) + @test Lf == L + @test Lf isa LowRankMatrix{Float64} + Lf = convert(AbstractMatrix{Float64}, L) + @test Lf == L + @test Lf isa AbstractMatrix{Float64} + Lf = convert(AbstractArray{Float64}, L) + @test Lf == L + @test Lf isa AbstractArray{Float64} +end @testset "LowRankMatrix algebra" begin A = LowRankMatrices._LowRankMatrix(randn(20,4), randn(12,4))