Skip to content

Commit

Permalink
Use Aqua and resolve ambiguities in convert (#14)
Browse files Browse the repository at this point in the history
* Use Aqua and resolve ambiguities in convert

* Add lower compat bounds for old Julia versions

* Add tests

* Bump version to v1.0.1
  • Loading branch information
jishnub authored Feb 10, 2024
1 parent 51ac1f7 commit 7fe7111
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
8 changes: 6 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LowRankMatrices"
uuid = "e65ccdef-c354-471a-8090-89bec1c20ec3"
authors = ["Jishnu Bhattacharya <[email protected]> and contributors"]
version = "1.0.0"
version = "1.0.1"

[deps]
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
Expand All @@ -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"]
7 changes: 4 additions & 3 deletions src/lowrankmatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down
7 changes: 7 additions & 0 deletions test/aqua.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Aqua
using LowRankMatrices
using Test

@testset "Project quality" begin
Aqua.test_all(LowRankMatrices)
end
16 changes: 16 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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))
Expand Down

2 comments on commit 7fe7111

@jishnub
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/100613

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.1 -m "<description of version>" 7fe711118ef3d5539815642cfe72940830950120
git push origin v1.0.1

Please sign in to comment.