Skip to content

Commit 8f8da3d

Browse files
authored
Merge pull request #290 from JuliaReach/schillic/ExplicitImports
Use ExplicitImports in tests and fix import issues
2 parents f16c693 + eb695fb commit 8f8da3d

File tree

10 files changed

+89
-61
lines changed

10 files changed

+89
-61
lines changed

src/IntervalMatrices.jl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
module IntervalMatrices
22

3-
using LinearAlgebra
4-
using LinearAlgebra: checksquare
5-
6-
using Random: AbstractRNG, GLOBAL_RNG, seed!
7-
import Random: rand
8-
9-
import Base: copy,
3+
import Base: copy, rand,
104
+, -, *, /, \,
115
size, IndexStyle, getindex, setindex!,
126
similar, , , , , real, imag
137

14-
using Reexport
8+
import LinearAlgebra
9+
using LinearAlgebra: Diagonal, I, UniformScaling, checksquare, opnorm
10+
using Random: AbstractRNG, GLOBAL_RNG
11+
using Reexport: @reexport
1512

1613
# =================================
1714
# Interface with IntervalArithmetic

src/exponential.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ end
8080
function _exp_remainder(A::IntervalMatrix{T}, t, p; n=checksquare(A)) where {T}
8181
C = max.(abs.(inf(A)), abs.(sup(A)))
8282
# compute Q = I + Ct + (Ct)^2/2! + ... + (Ct)^p/p!
83-
Q = Matrix(LinearAlgebra.Diagonal(ones(T, n)))
83+
Q = Matrix(Diagonal(ones(T, n)))
8484

8585
tⁱ = 1
8686
i! = 1

src/matrix.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,20 @@ julia> [1 2; 3 4] ± [1 2; 4 5]
173173
"""
174174
function ±(C::MT, S::MT) where {T,MT<:AbstractMatrix{T}}
175175
size(C) == size(S) || throw(ArgumentError("the sizes of the center matrix and the " *
176-
"radii matrix should match, but they are $(size(C)) " *
177-
"and $(size(S)) respectively"))
176+
"radii matrix should match, but they are " *
177+
"$(size(C)) and $(size(S)) respectively"))
178178

179179
return IntervalMatrix(map((x, y) -> interval(x - y, x + y), C, S))
180180
end
181181

182-
for op in (:Adjoint, :Bidiagonal, :Diagonal, :Hermitian,
183-
:SymTridiagonal, :Symmetric, :Transpose, :Tridiagonal)
184-
@eval LinearAlgebra.$op(A::IntervalMatrix) = IntervalMatrix($op(A.mat))
182+
for op in (:Adjoint, :Bidiagonal, :Diagonal, :Hermitian, :SymTridiagonal, :Symmetric, :Transpose,
183+
:Tridiagonal)
184+
@eval LinearAlgebra.$op(A::IntervalMatrix) = IntervalMatrix(LinearAlgebra.$op(A.mat))
185185
end
186186

187187
if VERSION >= v"1.3"
188-
LinearAlgebra.UpperHessenberg(A::IntervalMatrix) = IntervalMatrix(UpperHessenberg(A.mat))
188+
LinearAlgebra.UpperHessenberg(A::IntervalMatrix) =
189+
IntervalMatrix(LinearAlgebra.UpperHessenberg(A.mat))
189190
end
190191

191192
@static if vIA >= v"0.22"

src/operations/arithmetic.jl

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,26 @@
3434
# (there exist more precise approaches but are currently not implemented here)
3535
\(M1::IntervalMatrix, M2::IntervalMatrix) = IntervalMatrix(M1.mat \ M2.mat)
3636
# COV_EXCL_START
37-
for T in (:AbstractMatrix, :Diagonal, :(Union{UpperTriangular,LowerTriangular}),
38-
:(Union{UnitUpperTriangular,UnitLowerTriangular}), :SymTridiagonal, :Bidiagonal,
39-
:(LinearAlgebra.HermOrSym), :(LinearAlgebra.AdjOrTrans{<:Any,<:Bidiagonal}))
37+
for T in (:AbstractMatrix, :(LinearAlgebra.Diagonal),
38+
:(Union{LinearAlgebra.UpperTriangular,LinearAlgebra.LowerTriangular}),
39+
:(Union{LinearAlgebra.UnitUpperTriangular,LinearAlgebra.UnitLowerTriangular}),
40+
:(LinearAlgebra.SymTridiagonal), :(LinearAlgebra.Bidiagonal), :(LinearAlgebra.HermOrSym),
41+
:(LinearAlgebra.AdjOrTrans{<:Any,<:LinearAlgebra.Bidiagonal})) # NOTE: these are internal functions
4042
@eval begin
4143
\(M1::IntervalMatrix, M2::$T) = IntervalMatrix(M1.mat \ M2)
4244
\(M1::$T, M2::IntervalMatrix) = IntervalMatrix(M1 \ M2.mat)
4345
end
4446
end
4547
@static if VERSION >= v"1.3"
46-
for T in [:(Union{LinearAlgebra.Adjoint{T,
47-
S} where {T,
48-
S<:(LinearAlgebra.UpperHessenberg{T,
49-
S} where {S<:AbstractMatrix{T}})},
50-
LinearAlgebra.Transpose{T,
51-
S} where {T,
52-
S<:(LinearAlgebra.UpperHessenberg{T,
53-
S} where {S<:AbstractMatrix{T}})},
54-
LinearAlgebra.UpperHessenberg})]
48+
for T in [:(LinearAlgebra.Adjoint{T,
49+
S} where {T,
50+
S<:(LinearAlgebra.UpperHessenberg{T,
51+
S} where {S<:AbstractMatrix{T}})}),
52+
:(LinearAlgebra.Transpose{T,
53+
S} where {T,
54+
S<:(LinearAlgebra.UpperHessenberg{T,
55+
S} where {S<:AbstractMatrix{T}})}),
56+
:(LinearAlgebra.UpperHessenberg)]
5557
@eval begin
5658
\(M1::IntervalMatrix, M2::$T) = IntervalMatrix(M1.mat \ M2)
5759
\(M1::$T, M2::IntervalMatrix) = IntervalMatrix(M1 \ M2.mat)

src/operations/mult.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function set_multiplication_mode(multype)
3838

3939
# AbstractMatrix, incl. disambiguations
4040
for T in (:AbstractMatrix, :(LinearAlgebra.AbstractTriangular), # COV_EXCL_LINE
41-
:(Transpose{T,<:AbstractVector} where {T}), :Diagonal,
41+
:(LinearAlgebra.Transpose{T,<:AbstractVector} where {T}), :Diagonal,
4242
:(LinearAlgebra.Adjoint{T,<:AbstractVector} where {T}))
4343
@eval begin # COV_EXCL_LINE
4444
*(A::IntervalMatrix, B::$T) = *($type, A, B)

test/Aqua.jl

Lines changed: 0 additions & 28 deletions
This file was deleted.

test/Project.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
[deps]
22
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
33
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
4+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
45
PkgVersion = "eebad327-c553-4316-9ea0-9fa01ccd7688"
56
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
67
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
78

89
[compat]
910
Aqua = "0.8.9"
11+
ExplicitImports = "1"
12+
Pkg = "<0.0.1, 1.2"
1013
PkgVersion = "0.3.3"
14+
15+
[extras]
16+
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"

test/constructors.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ end
4848
A = rand(IntervalMatrix)
4949
@test A isa IntervalMatrix
5050

51-
Aₛ = Symmetric(A)
51+
Aₛ = LinearAlgebra.Symmetric(A)
5252
@test Aₛ isa IntervalMatrix
53-
@test Aₛ.mat isa Symmetric
53+
@test Aₛ.mat isa LinearAlgebra.Symmetric
5454
@test Matrix(Aₛ) isa Matrix
5555

5656
@static if VERSION >= v"1.3"
57-
Aₕ = UpperHessenberg(A)
57+
Aₕ = LinearAlgebra.UpperHessenberg(A)
5858
@test Aₕ isa IntervalMatrix
59-
@test Aₕ.mat isa UpperHessenberg
59+
@test Aₕ.mat isa LinearAlgebra.UpperHessenberg
6060
@test Matrix(Aₕ) isa Matrix
6161
end
6262
end

test/quality_assurance.jl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using IntervalMatrices, Test
2+
import PkgVersion, Aqua
3+
4+
import Pkg
5+
@static if VERSION >= v"1.6" # TODO make explicit test requirement
6+
Pkg.add("ExplicitImports")
7+
import ExplicitImports
8+
9+
@testset "ExplicitImports tests" begin
10+
ignores = (:GLOBAL_RNG,)
11+
@test isnothing(ExplicitImports.check_all_explicit_imports_are_public(IntervalMatrices;
12+
ignore=ignores))
13+
@test isnothing(ExplicitImports.check_all_explicit_imports_via_owners(IntervalMatrices))
14+
ignores = (:HermOrSym, :AdjOrTrans)
15+
@test isnothing(ExplicitImports.check_all_qualified_accesses_are_public(IntervalMatrices;
16+
ignore=ignores))
17+
@test isnothing(ExplicitImports.check_all_qualified_accesses_via_owners(IntervalMatrices))
18+
ignores = (:IntervalArithmetic, :Interval, :in_interval, :intersect_interval, :interval,
19+
:isequal_interval, :issubset_interval, :setdisplay) # due to reexporting IntervalArithmetic
20+
@test isnothing(ExplicitImports.check_no_implicit_imports(IntervalMatrices; ignore=ignores))
21+
@test isnothing(ExplicitImports.check_no_self_qualified_accesses(IntervalMatrices))
22+
@test isnothing(ExplicitImports.check_no_stale_explicit_imports(IntervalMatrices))
23+
end
24+
end
25+
26+
@testset "Aqua tests" begin
27+
# PkgVersion is only used in old versions
28+
@static if VERSION >= v"1.9"
29+
stale_deps = (ignore=[:PkgVersion],)
30+
else
31+
stale_deps = true
32+
end
33+
34+
# old versions of IntervalArithmetic had an undefined export
35+
@static if PkgVersion.Version(IntervalMatrices.IntervalArithmetic) >= v"0.17.6"
36+
undefined_exports = true
37+
else
38+
undefined_exports = false
39+
end
40+
41+
# old versions of IntervalArithmetic did not define `interval` for `Complex` inputs
42+
@static if PkgVersion.Version(IntervalMatrices.IntervalArithmetic) >= v"0.21"
43+
piracies = true
44+
else
45+
piracies = (broken=true,)
46+
end
47+
48+
Aqua.test_all(IntervalMatrices; stale_deps=stale_deps, undefined_exports=undefined_exports,
49+
piracies=piracies)
50+
end

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ include("setops.jl")
3030
include("exponential.jl")
3131
include("affine.jl")
3232

33-
include("Aqua.jl")
33+
include("quality_assurance.jl")

0 commit comments

Comments
 (0)