Skip to content

Commit

Permalink
Code quality cleanup (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarrasch authored Sep 4, 2023
1 parent 4e6776a commit 03ed9e3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ function LinearAlgebra.generic_trimatmul!(C::StridedVecOrMat, uploc, isunitc, tf
end
return C
end
function LinearAlgebra.generic_trimatmul!(C::StridedVecOrMat, uploc, isunitc, _, xA::AdjOrTrans{<:Any,<:SparseMatrixCSCUnion}, B::AbstractVecOrMat)
function LinearAlgebra.generic_trimatmul!(C::StridedVecOrMat, uploc, isunitc, ::Function, xA::AdjOrTrans{<:Any,<:SparseMatrixCSCUnion}, B::AbstractVecOrMat)
A = parent(xA)
nrowC = size(C, 1)
ncol = checksquare(A)
Expand Down
10 changes: 3 additions & 7 deletions test/ambiguous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ using Test, LinearAlgebra, SparseArrays, Aqua

@testset "code quality" begin
@testset "Method ambiguity" begin
# Aqua.test_ambiguities([SparseArrays, Base, Core])
Aqua.test_ambiguities([SparseArrays, Base, Core])
end
@testset "Unbound type parameters" begin
@test_broken Aqua.detect_unbound_args_recursively(SparseArrays) == []
end
@testset "Undefined exports" begin
Aqua.test_undefined_exports(SparseArrays) == []
Aqua.test_undefined_exports(SparseArrays)
end
@testset "Compare Project.toml and test/Project.toml" begin
Aqua.test_project_extras(SparseArrays)
Expand All @@ -53,13 +53,9 @@ using Test, LinearAlgebra, SparseArrays, Aqua
end

let ambig = detect_ambiguities(SparseArrays; recursive=true)
@test_broken isempty(ambig)
@test isempty(ambig)
ambig = Set{Any}(((m1.sig, m2.sig) for (m1, m2) in ambig))
expect = []
push!(expect, (Tuple{typeof(LinearAlgebra.generic_trimatmul!), AbstractVecOrMat, Any, Any, Function, AbstractMatrix, AbstractVecOrMat},
Tuple{typeof(LinearAlgebra.generic_trimatmul!), StridedVecOrMat, Any, Any, Any, Union{Adjoint{var"#s388", var"#s387"}, Transpose{var"#s388", var"#s387"}} where {var"#s388", var"#s387"<:(Union{SparseArrays.AbstractSparseMatrixCSC{Tv, Ti}, SubArray{Tv, 2, <:SparseArrays.AbstractSparseMatrixCSC{Tv, Ti}, Tuple{Base.Slice{Base.OneTo{Int}}, I}} where I<:AbstractUnitRange} where {Tv, Ti})}, AbstractVecOrMat}))
push!(expect, (Tuple{typeof(LinearAlgebra.generic_trimatmul!), AbstractVecOrMat, Any, Any, Function, Union{Adjoint{T, S}, Transpose{T, S}} where {T, S}, AbstractVecOrMat},
Tuple{typeof(LinearAlgebra.generic_trimatmul!), StridedVecOrMat, Any, Any, Any, Union{Adjoint{var"#s388", var"#s387"}, Transpose{var"#s388", var"#s387"}} where {var"#s388", var"#s387"<:(Union{SparseArrays.AbstractSparseMatrixCSC{Tv, Ti}, SubArray{Tv, 2, <:SparseArrays.AbstractSparseMatrixCSC{Tv, Ti}, Tuple{Base.Slice{Base.OneTo{Int}}, I}} where I<:AbstractUnitRange} where {Tv, Ti})}, AbstractVecOrMat}))
good = true
while !isempty(ambig)
sigs = pop!(ambig)
Expand Down
12 changes: 12 additions & 0 deletions test/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ begin
vMAW = tr(wr(view(MA, :, 1:n)))
@test vAW * B vMAW * B
end
a = sprand(rng, ComplexF64, n, n, 0.01)
ma = Matrix(a)
@testset "triangular multiply with conjugate matrices" for tr in (x -> adjoint(transpose(x)), x -> transpose(adjoint(x))),
wr in (UpperTriangular, LowerTriangular, UnitUpperTriangular, UnitLowerTriangular)
AW = tr(wr(a))
MAW = tr(wr(ma))
@test AW * B MAW * B
# and for SparseMatrixCSCView - a view of all rows and unit range of cols
vAW = tr(wr(view(a, :, 1:n)))
vMAW = tr(wr(view(ma, :, 1:n)))
@test vAW * B vMAW * B
end
A = A - Diagonal(diag(A)) + 2I # avoid rounding errors by division
MA = Matrix(A)
@testset "triangular solver for $tr($wr)" for tr in (identity, adjoint, transpose),
Expand Down

0 comments on commit 03ed9e3

Please sign in to comment.