diff --git a/.github/workflows/test-pull-request.yml b/.github/workflows/test-pull-request.yml index 74a4ab0..6ebe203 100644 --- a/.github/workflows/test-pull-request.yml +++ b/.github/workflows/test-pull-request.yml @@ -25,7 +25,7 @@ jobs: arch: - x64 include: - - version: '1.2' # test on oldest supported version + - version: '1.8' # test on oldest supported version arch: x64 os: ubuntu-slim env: diff --git a/Project.toml b/Project.toml index 1ef7eae..78f32fb 100644 --- a/Project.toml +++ b/Project.toml @@ -10,9 +10,9 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" [compat] -IntervalArithmetic = "0.15, 0.16, 0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 1" -LinearAlgebra = "<0.0.1, 1.2" +IntervalArithmetic = "0.21 - 0.23, 1" +LinearAlgebra = "<0.0.1, 1" PkgVersion = "0.3.3" -Random = "<0.0.1, 1.2" +Random = "<0.0.1, 1" Reexport = "0.2, 1" -julia = "1.2" +julia = "1.8" diff --git a/src/init_IntervalArithmetic.jl b/src/init_IntervalArithmetic.jl index 5aa2aa0..f7079a2 100644 --- a/src/init_IntervalArithmetic.jl +++ b/src/init_IntervalArithmetic.jl @@ -1,5 +1,5 @@ @reexport using IntervalArithmetic -import IntervalArithmetic: inf, sup, mid, diam, radius, hull +import IntervalArithmetic: diam, hull, inf, mid, numtype, radius, sup @static if VERSION >= v"1.9" vIA = pkgversion(IntervalArithmetic) @@ -8,18 +8,14 @@ else vIA = PkgVersion.Version(IntervalArithmetic) end -@static if vIA >= v"0.21.2" - import IntervalArithmetic: midradius -else - export midradius -end - @static if vIA >= v"0.22" import Base: intersect + import IntervalArithmetic: midradius export ± # not exported by IntervalArithmetic anymore else # vIA < v"0.22" # COV_EXCL_START import IntervalArithmetic: ± + export midradius issubset_interval(x::Interval, y::Interval) = issubset(x, y) diff --git a/src/matrix.jl b/src/matrix.jl index 304322a..10c9f18 100644 --- a/src/matrix.jl +++ b/src/matrix.jl @@ -73,14 +73,22 @@ getindex(M::IntervalMatrix, i::Int) = getindex(M.mat, i) setindex!(M::IntervalMatrix, X, inds...) = setindex!(M.mat, X, inds...) copy(M::IntervalMatrix) = IntervalMatrix(copy(M.mat)) -function IntervalMatrix(A::MT) where {T,IT<:Interval{T},MT<:AbstractMatrix{IT}} +function IntervalMatrix(A::MT) where {IT<:Interval,MT<:AbstractMatrix{IT}} + T = numtype(IT) return IntervalMatrix{T,IT,MT}(A) end -function IntervalMatrix(A::MT) where {T,IT<:Complex{Interval{T}},MT<:AbstractMatrix{IT}} +function IntervalMatrix(A::MT) where {IT<:Complex{<:Interval},MT<:AbstractMatrix{IT}} + T = _numtype(IT) return IntervalMatrix{T,IT,MT}(A) end +@static if vIA >= v"1" + _numtype(IT::Type{Complex{Interval{T}}}) where {T} = numtype(IT) +else + _numtype(IT::Type{Complex{Interval{T}}}) where {T} = T +end + # constructor from uniform scaling function IntervalMatrix(αI::UniformScaling{Interval{T}}, m::Integer, n::Integer=m) where {T} return IntervalMatrix(Matrix(αI, m, n)) @@ -184,10 +192,8 @@ for op in (:Adjoint, :Bidiagonal, :Diagonal, :Hermitian, :SymTridiagonal, :Symme @eval LinearAlgebra.$op(A::IntervalMatrix) = IntervalMatrix(LinearAlgebra.$op(A.mat)) end -if VERSION >= v"1.3" - function LinearAlgebra.UpperHessenberg(A::IntervalMatrix) - return IntervalMatrix(LinearAlgebra.UpperHessenberg(A.mat)) - end +function LinearAlgebra.UpperHessenberg(A::IntervalMatrix) + return 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 1e2c48c..2f102bc 100644 --- a/src/operations/arithmetic.jl +++ b/src/operations/arithmetic.jl @@ -44,20 +44,18 @@ for T in (:AbstractMatrix, :(LinearAlgebra.Diagonal), \(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})] - @eval begin - \(M1::IntervalMatrix, M2::$T) = IntervalMatrix(M1.mat \ M2) - \(M1::$T, M2::IntervalMatrix) = IntervalMatrix(M1 \ M2.mat) - end +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})] + @eval begin + \(M1::IntervalMatrix, M2::$T) = IntervalMatrix(M1.mat \ M2) + \(M1::$T, M2::IntervalMatrix) = IntervalMatrix(M1 \ M2.mat) end end # COV_EXCL_STOP diff --git a/test/Project.toml b/test/Project.toml index c739585..d696776 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,5 +1,6 @@ [deps] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" PkgVersion = "eebad327-c553-4316-9ea0-9fa01ccd7688" @@ -9,7 +10,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] Aqua = "0.8.9" ExplicitImports = "1" -JET = "0.9, 0.10, 0.11, 0.13" +JET = "0.9 - 0.13" LinearAlgebra = "<0.0.1, 1" Pkg = "<0.0.1, 1" PkgVersion = "0.3.3" @@ -17,5 +18,4 @@ SparseArrays = "<0.0.1, 1" Test = "<0.0.1, 1" [extras] -ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" diff --git a/test/constructors.jl b/test/constructors.jl index 8e27fee..8ca1039 100644 --- a/test/constructors.jl +++ b/test/constructors.jl @@ -53,10 +53,8 @@ end @test Aₛ.mat isa LinearAlgebra.Symmetric @test Matrix(Aₛ) isa Matrix - @static if VERSION >= v"1.3" - Aₕ = LinearAlgebra.UpperHessenberg(A) - @test Aₕ isa IntervalMatrix - @test Aₕ.mat isa LinearAlgebra.UpperHessenberg - @test Matrix(Aₕ) isa Matrix - end + Aₕ = LinearAlgebra.UpperHessenberg(A) + @test Aₕ isa IntervalMatrix + @test Aₕ.mat isa LinearAlgebra.UpperHessenberg + @test Matrix(Aₕ) isa Matrix end diff --git a/test/quality_assurance.jl b/test/quality_assurance.jl index 4426279..0f4a4c8 100644 --- a/test/quality_assurance.jl +++ b/test/quality_assurance.jl @@ -1,28 +1,31 @@ using IntervalMatrices, Test -import PkgVersion, Aqua +import PkgVersion, Aqua, ExplicitImports -import Pkg -@static if VERSION >= v"1.6" # TODO make explicit test requirement - Pkg.add("ExplicitImports") - import ExplicitImports - - @testset "ExplicitImports tests" begin +@testset "ExplicitImports tests" begin + @static if PkgVersion.Version(IntervalMatrices.IntervalArithmetic) >= v"0.22" 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)) + else + ignores = (:GLOBAL_RNG, :checksquare, :numtype) + end + @test isnothing(ExplicitImports.check_all_explicit_imports_are_public(IntervalMatrices; + ignore=ignores)) + @test isnothing(ExplicitImports.check_all_explicit_imports_via_owners(IntervalMatrices)) + @static if VERSION >= v"1.9" 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)) + else + ignores = (:HermOrSym, :AdjOrTrans, :AbstractTriangular, :Version) end + @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 +import Pkg @static if VERSION >= v"1.10" # JET v0.9.0 (earliest supported version) requires Julia v1.10 Pkg.add("JET") @@ -38,24 +41,19 @@ end # PkgVersion is only used in old versions @static if VERSION >= v"1.9" stale_deps = (ignore=[:PkgVersion],) + ambiguities = true else stale_deps = true + ambiguities = (broken=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" + # old versions of IntervalArithmetic did not define `convert` + @static if PkgVersion.Version(IntervalMatrices.IntervalArithmetic) >= v"0.22" piracies = true else piracies = (broken=true,) end - Aqua.test_all(IntervalMatrices; stale_deps=stale_deps, undefined_exports=undefined_exports, + Aqua.test_all(IntervalMatrices; stale_deps=stale_deps, ambiguities=ambiguities, piracies=piracies) end