diff --git a/src/IntervalMatrices.jl b/src/IntervalMatrices.jl index 3213c04..5a94996 100644 --- a/src/IntervalMatrices.jl +++ b/src/IntervalMatrices.jl @@ -1,17 +1,14 @@ module IntervalMatrices -using LinearAlgebra -using LinearAlgebra: checksquare - -using Random: AbstractRNG, GLOBAL_RNG, seed! -import Random: rand - -import Base: copy, +import Base: copy, rand, +, -, *, /, \, size, IndexStyle, getindex, setindex!, similar, ∈, ⊆, ∩, ∪, real, imag -using Reexport +import LinearAlgebra +using LinearAlgebra: Diagonal, I, UniformScaling, checksquare, opnorm +using Random: AbstractRNG, GLOBAL_RNG +using Reexport: @reexport # ================================= # Interface with IntervalArithmetic diff --git a/src/exponential.jl b/src/exponential.jl index dc30b0c..a0ae517 100644 --- a/src/exponential.jl +++ b/src/exponential.jl @@ -80,7 +80,7 @@ end function _exp_remainder(A::IntervalMatrix{T}, t, p; n=checksquare(A)) where {T} C = max.(abs.(inf(A)), abs.(sup(A))) # compute Q = I + Ct + (Ct)^2/2! + ... + (Ct)^p/p! - Q = Matrix(LinearAlgebra.Diagonal(ones(T, n))) + Q = Matrix(Diagonal(ones(T, n))) tⁱ = 1 i! = 1 diff --git a/src/matrix.jl b/src/matrix.jl index fec40b6..caf4c4f 100644 --- a/src/matrix.jl +++ b/src/matrix.jl @@ -173,19 +173,20 @@ julia> [1 2; 3 4] ± [1 2; 4 5] """ function ±(C::MT, S::MT) where {T,MT<:AbstractMatrix{T}} size(C) == size(S) || throw(ArgumentError("the sizes of the center matrix and the " * - "radii matrix should match, but they are $(size(C)) " * - "and $(size(S)) respectively")) + "radii matrix should match, but they are " * + "$(size(C)) and $(size(S)) respectively")) return IntervalMatrix(map((x, y) -> interval(x - y, x + y), C, S)) end -for op in (:Adjoint, :Bidiagonal, :Diagonal, :Hermitian, - :SymTridiagonal, :Symmetric, :Transpose, :Tridiagonal) - @eval LinearAlgebra.$op(A::IntervalMatrix) = IntervalMatrix($op(A.mat)) +for op in (:Adjoint, :Bidiagonal, :Diagonal, :Hermitian, :SymTridiagonal, :Symmetric, :Transpose, + :Tridiagonal) + @eval LinearAlgebra.$op(A::IntervalMatrix) = IntervalMatrix(LinearAlgebra.$op(A.mat)) end if VERSION >= v"1.3" - LinearAlgebra.UpperHessenberg(A::IntervalMatrix) = IntervalMatrix(UpperHessenberg(A.mat)) + LinearAlgebra.UpperHessenberg(A::IntervalMatrix) = + IntervalMatrix(LinearAlgebra.UpperHessenberg(A.mat)) end @static if vIA >= v"0.22" diff --git a/src/operations/arithmetic.jl b/src/operations/arithmetic.jl index da2f01b..03ca497 100644 --- a/src/operations/arithmetic.jl +++ b/src/operations/arithmetic.jl @@ -34,24 +34,26 @@ # (there exist more precise approaches but are currently not implemented here) \(M1::IntervalMatrix, M2::IntervalMatrix) = IntervalMatrix(M1.mat \ M2.mat) # COV_EXCL_START -for T in (:AbstractMatrix, :Diagonal, :(Union{UpperTriangular,LowerTriangular}), - :(Union{UnitUpperTriangular,UnitLowerTriangular}), :SymTridiagonal, :Bidiagonal, - :(LinearAlgebra.HermOrSym), :(LinearAlgebra.AdjOrTrans{<:Any,<:Bidiagonal})) +for T in (:AbstractMatrix, :(LinearAlgebra.Diagonal), + :(Union{LinearAlgebra.UpperTriangular,LinearAlgebra.LowerTriangular}), + :(Union{LinearAlgebra.UnitUpperTriangular,LinearAlgebra.UnitLowerTriangular}), + :(LinearAlgebra.SymTridiagonal), :(LinearAlgebra.Bidiagonal), :(LinearAlgebra.HermOrSym), + :(LinearAlgebra.AdjOrTrans{<:Any,<:LinearAlgebra.Bidiagonal})) # NOTE: these are internal functions @eval begin \(M1::IntervalMatrix, M2::$T) = IntervalMatrix(M1.mat \ M2) \(M1::$T, M2::IntervalMatrix) = IntervalMatrix(M1 \ M2.mat) end end @static if VERSION >= v"1.3" - for T in [:(Union{LinearAlgebra.Adjoint{T, - S} where {T, - S<:(LinearAlgebra.UpperHessenberg{T, - S} where {S<:AbstractMatrix{T}})}, - LinearAlgebra.Transpose{T, - S} where {T, - S<:(LinearAlgebra.UpperHessenberg{T, - S} where {S<:AbstractMatrix{T}})}, - LinearAlgebra.UpperHessenberg})] + for T in [:(LinearAlgebra.Adjoint{T, + S} where {T, + S<:(LinearAlgebra.UpperHessenberg{T, + S} where {S<:AbstractMatrix{T}})}), + :(LinearAlgebra.Transpose{T, + S} where {T, + S<:(LinearAlgebra.UpperHessenberg{T, + S} where {S<:AbstractMatrix{T}})}), + :(LinearAlgebra.UpperHessenberg)] @eval begin \(M1::IntervalMatrix, M2::$T) = IntervalMatrix(M1.mat \ M2) \(M1::$T, M2::IntervalMatrix) = IntervalMatrix(M1 \ M2.mat) diff --git a/src/operations/mult.jl b/src/operations/mult.jl index 2bd241e..2ce6800 100644 --- a/src/operations/mult.jl +++ b/src/operations/mult.jl @@ -38,7 +38,7 @@ function set_multiplication_mode(multype) # AbstractMatrix, incl. disambiguations for T in (:AbstractMatrix, :(LinearAlgebra.AbstractTriangular), # COV_EXCL_LINE - :(Transpose{T,<:AbstractVector} where {T}), :Diagonal, + :(LinearAlgebra.Transpose{T,<:AbstractVector} where {T}), :Diagonal, :(LinearAlgebra.Adjoint{T,<:AbstractVector} where {T})) @eval begin # COV_EXCL_LINE *(A::IntervalMatrix, B::$T) = *($type, A, B) diff --git a/test/Aqua.jl b/test/Aqua.jl deleted file mode 100644 index 9dfda08..0000000 --- a/test/Aqua.jl +++ /dev/null @@ -1,28 +0,0 @@ -using IntervalMatrices, Test -import PkgVersion, Aqua - -@testset "Aqua tests" begin - # PkgVersion is only used in old versions - @static if VERSION >= v"1.9" - stale_deps = (ignore=[:PkgVersion],) - else - stale_deps = true - end - - # old versions of IntervalArithmetic had an undefined export - @static if PkgVersion.Version(IntervalMatrices.IntervalArithmetic) >= v"0.17.6" - undefined_exports = true - else - undefined_exports = false - end - - # old versions of IntervalArithmetic did not define `interval` for `Complex` inputs - @static if PkgVersion.Version(IntervalMatrices.IntervalArithmetic) >= v"0.21" - piracies = true - else - piracies = (broken=true,) - end - - Aqua.test_all(IntervalMatrices; stale_deps=stale_deps, undefined_exports=undefined_exports, - piracies=piracies) -end diff --git a/test/Project.toml b/test/Project.toml index 2a2525d..9a9cef0 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,10 +1,16 @@ [deps] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" PkgVersion = "eebad327-c553-4316-9ea0-9fa01ccd7688" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] Aqua = "0.8.9" +ExplicitImports = "1" +Pkg = "<0.0.1, 1.2" PkgVersion = "0.3.3" + +[extras] +ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" diff --git a/test/constructors.jl b/test/constructors.jl index 41e944a..f9a8244 100644 --- a/test/constructors.jl +++ b/test/constructors.jl @@ -48,15 +48,15 @@ end A = rand(IntervalMatrix) @test A isa IntervalMatrix - Aₛ = Symmetric(A) + Aₛ = LinearAlgebra.Symmetric(A) @test Aₛ isa IntervalMatrix - @test Aₛ.mat isa Symmetric + @test Aₛ.mat isa LinearAlgebra.Symmetric @test Matrix(Aₛ) isa Matrix @static if VERSION >= v"1.3" - Aₕ = UpperHessenberg(A) + Aₕ = LinearAlgebra.UpperHessenberg(A) @test Aₕ isa IntervalMatrix - @test Aₕ.mat isa UpperHessenberg + @test Aₕ.mat isa LinearAlgebra.UpperHessenberg @test Matrix(Aₕ) isa Matrix end end diff --git a/test/quality_assurance.jl b/test/quality_assurance.jl new file mode 100644 index 0000000..a23bd2b --- /dev/null +++ b/test/quality_assurance.jl @@ -0,0 +1,50 @@ +using IntervalMatrices, Test +import PkgVersion, Aqua + +import Pkg +@static if VERSION >= v"1.6" # TODO make explicit test requirement + Pkg.add("ExplicitImports") + import ExplicitImports + + @testset "ExplicitImports tests" begin + ignores = (:GLOBAL_RNG,) + @test isnothing(ExplicitImports.check_all_explicit_imports_are_public(IntervalMatrices; + ignore=ignores)) + @test isnothing(ExplicitImports.check_all_explicit_imports_via_owners(IntervalMatrices)) + ignores = (:HermOrSym, :AdjOrTrans) + @test isnothing(ExplicitImports.check_all_qualified_accesses_are_public(IntervalMatrices; + ignore=ignores)) + @test isnothing(ExplicitImports.check_all_qualified_accesses_via_owners(IntervalMatrices)) + ignores = (:IntervalArithmetic, :Interval, :in_interval, :intersect_interval, :interval, + :isequal_interval, :issubset_interval, :setdisplay) # due to reexporting IntervalArithmetic + @test isnothing(ExplicitImports.check_no_implicit_imports(IntervalMatrices; ignore=ignores)) + @test isnothing(ExplicitImports.check_no_self_qualified_accesses(IntervalMatrices)) + @test isnothing(ExplicitImports.check_no_stale_explicit_imports(IntervalMatrices)) + end +end + +@testset "Aqua tests" begin + # PkgVersion is only used in old versions + @static if VERSION >= v"1.9" + stale_deps = (ignore=[:PkgVersion],) + else + stale_deps = true + end + + # old versions of IntervalArithmetic had an undefined export + @static if PkgVersion.Version(IntervalMatrices.IntervalArithmetic) >= v"0.17.6" + undefined_exports = true + else + undefined_exports = false + end + + # old versions of IntervalArithmetic did not define `interval` for `Complex` inputs + @static if PkgVersion.Version(IntervalMatrices.IntervalArithmetic) >= v"0.21" + piracies = true + else + piracies = (broken=true,) + end + + Aqua.test_all(IntervalMatrices; stale_deps=stale_deps, undefined_exports=undefined_exports, + piracies=piracies) +end diff --git a/test/runtests.jl b/test/runtests.jl index 5ce7691..0f8d009 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -30,4 +30,4 @@ include("setops.jl") include("exponential.jl") include("affine.jl") -include("Aqua.jl") +include("quality_assurance.jl")