Skip to content

Commit

Permalink
Merge pull request #233 from JuliaReach/schillic/equality
Browse files Browse the repository at this point in the history
Avoid redefinition of '==' in tests
  • Loading branch information
schillic committed Sep 9, 2024
2 parents ae89a1b + 7f1d9fc commit cde766c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
12 changes: 6 additions & 6 deletions test/affine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
P = AffineIntervalMatrix1(A0, A1, λ)

@test size(P) == (2, 2)
@test P[1, 1] == interval(1)
@test P[1, 2] == interval(0, 1)
@test P[1, 1] interval(1)
@test P[1, 2] interval(0, 1)
P[1, 1] = 2.0
@test P[1, 1] == interval(2)
@test P[1, 1] interval(2)

Q = copy(P)
@test Q == P && Q isa AffineIntervalMatrix1
Expand All @@ -28,10 +28,10 @@ end
P = AffineIntervalMatrix(A0, [A1, A2], [λ1, λ2])

@test size(P) == (2, 2)
@test P[1, 1] == interval(1)
@test P[1, 2] == interval(0, 2)
@test P[1, 1] interval(1)
@test P[1, 2] interval(0, 2)
P[1, 1] = 5.0
@test P[1, 1] == interval(5)
@test P[1, 1] interval(5)

Q = copy(P)
@test Q == P && Q isa AffineIntervalMatrix
Expand Down
10 changes: 5 additions & 5 deletions test/arithmetic.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@testset "Interval arithmetic" begin
a = interval(-2, -1)
b = interval(-1, 1)
@test a + b == interval(-3, 0)
@test a * b == interval(-2, 2)
@test a * b + a == interval(-4, 1)
@test a * (b + 1) == interval(-4, 0)
@test a + b interval(-3, 0)
@test a * b interval(-2, 2)
@test a * b + a interval(-4, 1)
@test a * (b + 1) interval(-4, 0)
end

@testset "Interval matrix arithmetic" begin
Expand All @@ -27,7 +27,7 @@ end

B = A - A
@test B isa IntervalMatrix && inf(B[1, 1]) inf(a₋) && sup(B[1, 1]) sup(a₋) &&
B[1, 2] == b₋ && B[2, 1] == c₋ && B[2, 2] == d₋
B[1, 2] b₋ && B[2, 1] c₋ && B[2, 2] d₋

# arithmetic with an interval or number
for x in (interval(0, 2), 2.0)
Expand Down
4 changes: 2 additions & 2 deletions test/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
y = convert(Interval{Float64}, x)
# `===` is not applicable here because it just checks value equivalence
# for (immutable) `Interval`s
@test y == x && y isa Interval{Float64}
@test y x && y isa Interval{Float64}

y = convert(Interval{Float32}, x)
@test y == x && y isa Interval{Float32}
@test y x && y isa Interval{Float32}
end

@testset "Interval matrix construction" begin
Expand Down
4 changes: 2 additions & 2 deletions test/exponential.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using IntervalMatrices: TaylorOverapproximation,
_exp_remainder_series

@testset "Interval matrix exponential" begin
@test quadratic_expansion(interval(-3, 3), 1.0, 2.0) == interval(-0.125, 21)
@test quadratic_expansion(interval(-3, 3), 1.0, 2.0) interval(-0.125, 21)

M = IntervalMatrix([interval(-1.1, 0.9) interval(-4.1, -3.9);
interval(3.9, 4.1) interval(-1.1, 0.9)])
Expand Down Expand Up @@ -59,7 +59,7 @@ end

@test base(pow) === m
@test get(pow) === pow.Mᵏ
@test index(pow) === 1
@test index(pow) == 1

pow2 = copy(pow)
@test pow2 isa IntervalMatrixPower && get(pow) == get(pow2)
Expand Down
6 changes: 4 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ using IntervalMatrices: _truncated_exponential_series,
correction_hull,
input_correction

# IntervalArithmetic removed interval comparison in v0.22
@static if PkgVersion.Version(IntervalMatrices.IntervalArithmetic) >= v"0.22"
# equality test for convenience
Base.:(==)(x::Interval, y::Interval) = isequal_interval(x, y)
(x::Interval, y::Interval) = isequal_interval(x, y)
else
(x::Interval, y::Interval) = ==(x, y)
end

include("models.jl")
Expand Down
2 changes: 1 addition & 1 deletion test/setops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ end
for i in 1:3
# sample a random interval from the matrix (Base method)
mr = rand(m)
@test mr m && mr isa Interval
@test any(mr y for y in m) && mr isa Interval

# sample a concrete matrix instantiation
ms = sample(m)
Expand Down

0 comments on commit cde766c

Please sign in to comment.