Skip to content

Commit 66caa49

Browse files
authored
Merge pull request #3667 from JuliaReach/schillic/emptyset_radius
`EmptySet`: redefine `norm`/`radius`/`diameter`
2 parents 7f91a60 + d659760 commit 66caa49

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

src/API/Unary/diameter.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ A real number representing the diameter.
1616
1717
The diameter of a set is the maximum distance between any two elements of the
1818
set, or, equivalently, the diameter of the enclosing ball (of the given
19-
``p``-norm) of minimal volume with the same center.
19+
``p``-norm) of minimal volume.
2020
"""
2121
function diameter(::LazySet, ::Real=Inf) end

src/API/Unary/radius.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ A real number representing the radius.
1515
### Notes
1616
1717
The radius of a set is the radius of the enclosing ball (of the given
18-
``p``-norm) of minimal volume with the same center.
18+
``p``-norm) of minimal volume.
1919
"""
2020
function radius(::LazySet, ::Real=Inf) end

src/Sets/EmptySet/diameter.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
function diameter(::EmptySet, ::Real=Inf)
2-
throw(ArgumentError("the diameter of an empty set is undefined"))
1+
function diameter(∅::EmptySet, ::Real=Inf)
2+
N = eltype(∅)
3+
return zero(N)
34
end

src/Sets/EmptySet/norm.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
function norm(::EmptySet, ::Real=Inf)
2-
throw(ArgumentError("the norm of an empty set is undefined"))
1+
function norm(∅::EmptySet, ::Real=Inf)
2+
N = eltype(∅)
3+
return zero(N)
34
end

src/Sets/EmptySet/radius.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
function radius(::EmptySet, ::Real=Inf)
2-
throw(ArgumentError("the radius of an empty set is undefined"))
1+
function radius(∅::EmptySet, ::Real=Inf)
2+
N = eltype(∅)
3+
return zero(N)
34
end

test/Sets/EmptySet.jl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@ for N in [Float64, Float32, Rational{Int}]
8080
end
8181

8282
# diameter
83-
@test_throws ArgumentError diameter(E) # TODO this should maybe change
84-
# res = diameter(E)
85-
# @test res isa N && res == N(0)
83+
res = diameter(E)
84+
@test res isa N && res == N(0)
8685

8786
# dim
8887
@test dim(E) == 2
@@ -129,19 +128,17 @@ for N in [Float64, Float32, Rational{Int}]
129128
@test_throws ArgumentError low(E, 1)
130129

131130
# norm
132-
@test_throws ArgumentError norm(E) # TODO this should maybe change
133-
# res = norm(E)
134-
# @test res isa N && res == N(0)
131+
res = norm(E)
132+
@test res isa N && res == N(0)
135133

136134
# polyhedron
137135
if test_suite_polyhedra
138136
@test_throws MethodError polyhedron(E) # TODO this should maybe change
139137
end
140138

141139
# radius
142-
@test_throws ArgumentError radius(E) # TODO this should maybe change
143-
# res = radius(E)
144-
# @test res isa N && res == N(0)
140+
res = radius(E)
141+
@test res isa N && res == N(0)
145142

146143
# rand
147144
E2 = rand(EmptySet; N=N)

0 commit comments

Comments
 (0)