Skip to content

Commit b64b9cb

Browse files
authored
Merge pull request #959 from JuliaReach/schillic/453
#453 - Fix low/high
2 parents 3493f51 + b3bf546 commit b64b9cb

File tree

8 files changed

+25
-26
lines changed

8 files changed

+25
-26
lines changed

docs/src/lib/representations.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ dim(::Interval)
239239
an_element(::Interval{N}) where {N<:Real}
240240
vertices_list(::Interval{N}) where {N<:Real}
241241
center(::Interval{N}) where {N<:Real}
242-
low(::Interval{N}) where {N<:Real}
243-
high(::Interval{N}) where {N<:Real}
242+
min(::Interval{N}) where {N<:Real}
243+
max(::Interval{N}) where {N<:Real}
244244
radius_hyperrectangle(::Interval{N}) where {N<:Real}
245245
radius_hyperrectangle(::Interval{N}, ::Int) where {N<:Real}
246246
+(::Interval{N}, ::Interval{N}) where {N<:Real}

src/AbstractHyperrectangle.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import Base.∈
22

33
export AbstractHyperrectangle,
44
radius_hyperrectangle,
5-
constraints_list
5+
constraints_list,
6+
low, high
67

78
"""
89
AbstractHyperrectangle{N<:Real} <: AbstractCentrallySymmetricPolytope{N}

src/Hyperrectangle.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import Base.rand
22

3-
export Hyperrectangle,
4-
low,
5-
high
3+
export Hyperrectangle
64

75
"""
86
Hyperrectangle{N<:Real} <: AbstractHyperrectangle{N}

src/Interval.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import IntervalArithmetic
22
import IntervalArithmetic: AbstractInterval
3-
import Base: +, -, *, , , rand
3+
import Base: +, -, *, , , rand, min, max
44

55
export Interval,
66
dim, σ, center,
7-
low, high, vertices_list
7+
vertices_list
88

99
"""
1010
Interval{N<:Real, IN <: AbstractInterval{N}} <: AbstractHyperrectangle{N}
@@ -254,7 +254,7 @@ function ∈(v::N, x::Interval{N}) where {N<:Real}
254254
end
255255

256256
"""
257-
low(x::Interval{N})::N where {N<:Real}
257+
min(x::Interval{N})::N where {N<:Real}
258258
259259
Return the lower component of an interval.
260260
@@ -266,12 +266,12 @@ Return the lower component of an interval.
266266
267267
The lower (`lo`) component of the interval.
268268
"""
269-
function low(x::Interval{N})::N where {N<:Real}
269+
function min(x::Interval{N})::N where {N<:Real}
270270
return x.dat.lo
271271
end
272272

273273
"""
274-
high(x::Interval{N})::N where {N<:Real}
274+
max(x::Interval{N})::N where {N<:Real}
275275
276276
Return the higher or upper component of an interval.
277277
@@ -283,7 +283,7 @@ Return the higher or upper component of an interval.
283283
284284
The higher (`hi`) component of the interval.
285285
"""
286-
function high(x::Interval{N})::N where {N<:Real}
286+
function max(x::Interval{N})::N where {N<:Real}
287287
return x.dat.hi
288288
end
289289

@@ -298,10 +298,10 @@ Return some element of an interval.
298298
299299
### Output
300300
301-
The left border (`low(x)`) of the interval.
301+
The left border (`min(x)`) of the interval.
302302
"""
303303
function an_element(x::Interval{N})::Vector{N} where {N<:Real}
304-
return [low(x)]
304+
return [min(x)]
305305
end
306306

307307
"""
@@ -354,7 +354,7 @@ Return the list of vertices of this interval.
354354
The list of vertices of the interval represented as two one-dimensional vectors.
355355
"""
356356
function vertices_list(x::Interval{N})::Vector{Vector{N}} where {N<:Real}
357-
return [[low(x)], [high(x)]]
357+
return [[min(x)], [max(x)]]
358358
end
359359

360360

@@ -377,7 +377,7 @@ The box radius in the given dimension.
377377
"""
378378
function radius_hyperrectangle(x::Interval{N}, i::Int)::N where {N<:Real}
379379
@assert i == 1 "an interval is one-dimensional"
380-
return (high(x) - low(x)) / N(2)
380+
return (max(x) - min(x)) / N(2)
381381
end
382382

383383
"""

src/concrete_intersection.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ Otherwise the result is the interval that describes the intersection.
120120
function intersection(x::Interval{N},
121121
y::Interval{N}
122122
)::Union{Interval{N}, EmptySet{N}} where {N<:Real}
123-
if low(y) > high(x) || low(x) > high(y)
123+
if min(y) > max(x) || min(x) > max(y)
124124
return EmptySet{N}()
125125
else
126-
return Interval(max(low(x), low(y)), min(high(x), high(y)))
126+
return Interval(max(min(x), min(y)), min(max(x), max(y)))
127127
end
128128
end
129129

src/convert.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ Hyperrectangle{Float64}([0.5], [0.5])
339339
```
340340
"""
341341
function convert(::Type{Hyperrectangle}, x::Interval)
342-
return Hyperrectangle(low=[low(x)], high=[high(x)])
342+
return Hyperrectangle(low=[min(x)], high=[max(x)])
343343
end
344344

345345
"""

src/plot_recipes.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ julia> plot(I);
484484
markershape --> (add_marker ? :circle : :none)
485485
markercolor --> color
486486

487-
[Tuple([low(I), 0.0]); Tuple([high(I), 0.0])]
487+
[Tuple([min(I), 0.0]); Tuple([max(I), 0.0])]
488488
end
489489

490490
"""
@@ -519,6 +519,6 @@ julia> plot([I1, I2]);
519519
markercolor --> color
520520

521521
for Ii in Xk
522-
@series [Tuple([low(Ii), 0.0]); Tuple([high(Ii), 0.0])]
522+
@series [Tuple([min(Ii), 0.0]); Tuple([max(Ii), 0.0])]
523523
end
524524
end

test/unit_Interval.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ for N in [Float64, Float32, Rational{Int}]
1515

1616
@test dim(x) == 1
1717
@test center(x) == N[0.5]
18-
@test low(x) == N(0) && high(x) == N(1)
18+
@test min(x) == N(0) && max(x) == N(1)
1919
v = vertices_list(x)
2020
@test N[0] in v && N[1] in v
2121
# test interface method an_element and membership
@@ -35,7 +35,7 @@ for N in [Float64, Float32, Rational{Int}]
3535
@test dim(m) == 1
3636
@test σ(N[1], m) == N[1.5]
3737
@test σ(N[-1], m) == N[-2]
38-
@test low(m) == N(-2) && high(m) == N(1.5)
38+
@test min(m) == N(-2) && max(m) == N(1.5)
3939
v = vertices_list(m)
4040
@test N[1.5] in v && N[-2] in v
4141

@@ -44,7 +44,7 @@ for N in [Float64, Float32, Rational{Int}]
4444
@test dim(d) == 1
4545
@test σ(N[1], d) == N[3]
4646
@test σ(N[-1], d) == N[-0.5]
47-
@test low(d) == N(-0.5) && high(d) == N(3)
47+
@test min(d) == N(-0.5) && max(d) == N(3)
4848
v = vertices_list(d)
4949
@test N[-0.5] in v && N[3] in v
5050

@@ -58,7 +58,7 @@ for N in [Float64, Float32, Rational{Int}]
5858

5959
# test different arithmetic operations
6060
r = (x + y) - (d + p)
61-
@test low(r) == N(-5.5) && high(r) == N(4)
61+
@test min(r) == N(-5.5) && max(r) == N(4)
6262

6363
# isempty
6464
@test !isempty(x)
@@ -87,7 +87,7 @@ for N in [Float64, Float32, Rational{Int}]
8787
B = Interval(N(3), N(6))
8888
C = intersection(A, B)
8989
@test C isa Interval
90-
@test low(C) == N(5) && high(C) == N(6)
90+
@test min(C) == N(5) && max(C) == N(6)
9191
# check empty intersection
9292
E = intersection(A, Interval(N(0), N(1)))
9393
@test isempty(E)

0 commit comments

Comments
 (0)