Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 3 additions & 7 deletions src/init_IntervalArithmetic.jl
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)

Expand Down
18 changes: 12 additions & 6 deletions src/matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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"
Expand Down
26 changes: 12 additions & 14 deletions src/operations/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -9,13 +10,12 @@ 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"
SparseArrays = "<0.0.1, 1"
Test = "<0.0.1, 1"

[extras]
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
10 changes: 4 additions & 6 deletions test/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
54 changes: 26 additions & 28 deletions test/quality_assurance.jl
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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
Loading