Skip to content

Commit

Permalink
EmptySet: shorten docs & throw ArgumentErrors
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Dec 12, 2024
1 parent b7a2d8e commit 94a7e6c
Show file tree
Hide file tree
Showing 26 changed files with 31 additions and 378 deletions.
4 changes: 2 additions & 2 deletions docs/src/lib/sets/EmptySet.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Undocumented implementations:
* [`isconvextype`](@ref isconvextype(::Type{LazySet}))
* [`isempty`](@ref isempty(::LazySet))
* [`isoperationtype`](@ref isoperationtype(::Type{LazySet}))
* [`isuniversal`](@ref isuniversal(::LazySet{N}, ::Bool=false) where {N})
* [`isuniversal`](@ref isuniversal(::LazySet, ::Bool=false))
* [`low`](@ref low(::LazySet))
* [`low`](@ref low(::LazySet, ::Int))
* [`norm`](@ref norm(::LazySet, ::Real=Inf))
Expand All @@ -45,7 +45,7 @@ Undocumented implementations:
* [`reflect`](@ref reflect(::LazySet))
* [`vertices_list`](@ref vertices_list(::LazySet))
* [`vertices`](@ref vertices(::LazySet))
* [`volume`](@ref volume(::LazySet{N}) where {N})
* [`volume`](@ref volume(::LazySet))
* [``](@ref ∈(::AbstractVector, ::LazySet))
* [`linear_map`](@ref linear_map(::AbstractMatrix, ::LazySet))
* [`ρ`](@ref ρ(::AbstractVector, ::LazySet))
Expand Down
15 changes: 1 addition & 14 deletions src/Sets/EmptySet/an_element.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
"""
an_element(∅::EmptySet)
Return some element of an empty set.
### Input
- `∅` -- empty set
### Output
An error.
"""
function an_element(::EmptySet)
return error("an empty set does not contain any element")
throw(ArgumentError("an empty set does not contain any element"))
end
13 changes: 0 additions & 13 deletions src/Sets/EmptySet/area.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
"""
area(∅::EmptySet)
Return the area of an empty set.
### Input
- `∅` -- empty set
### Output
``0``.
"""
function area(∅::EmptySet)
N = eltype(∅)
return zero(N)
Expand Down
2 changes: 1 addition & 1 deletion src/Sets/EmptySet/chebyshev_center_radius.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ and the corresponding radius of an empty set.
An error.
"""
function chebyshev_center_radius(∅::EmptySet; kwargs...)
return error("the Chebyshev center and radius of an empty set are undefined")
throw(ArgumentError("the Chebyshev center and radius of an empty set are undefined"))
end
10 changes: 3 additions & 7 deletions src/Sets/EmptySet/complement.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
"""
complement(∅::EmptySet{N}) where {N}
Return the complement of an empty set.
# Extended help
### Input
- `∅` -- empty set
complement(∅::EmptySet{N}) where {N}
### Output
The universe of the same dimension.
The [`Universe`](@ref) of the same dimension.
"""
function complement(∅::EmptySet{N}) where {N}
require(@__MODULE__, :LazySets; fun_name="complement")
Expand Down
19 changes: 1 addition & 18 deletions src/Sets/EmptySet/diameter.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
"""
diameter(∅::EmptySet, [p]::Real=Inf)
Return the diameter of an empty set.
It is the maximum distance between any two elements of the set or, equivalently,
the diameter of the enclosing ball (of the given ``p``-norm) of minimal volume
with the same center.
### Input
- `∅` -- empty set
- `p` -- (optional, default: `Inf`) norm
### Output
An error.
"""
function diameter(::EmptySet, ::Real=Inf)
return error("the diameter of an empty set is undefined")
throw(ArgumentError("the diameter of an empty set is undefined"))
end
13 changes: 0 additions & 13 deletions src/Sets/EmptySet/dim.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
"""
dim(∅::EmptySet)
Return the dimension of an empty set.
### Input
- `∅` -- an empty set
### Output
The dimension of the empty set.
"""
function dim(∅::EmptySet)
return.dim
end
36 changes: 2 additions & 34 deletions src/Sets/EmptySet/high.jl
Original file line number Diff line number Diff line change
@@ -1,39 +1,7 @@
"""
high(∅::EmptySet)
Return a vector with the highest coordinates of an empty set in each canonical
direction.
### Input
- `∅` -- empty set
### Output
An error.
### Notes
See also [`high(∅::EmptySet, i::Int)`](@ref).
"""
function high(::EmptySet)
return error("the upper bound of an empty set is undefined")
throw(ArgumentError("the upper bound of an empty set is undefined"))
end

"""
high(∅::EmptySet, i::Int)
Return the highest coordinate of an empty set in the given direction.
### Input
- `∅` -- empty set
- `i` -- dimension of interest
### Output
An error.
"""
function high(::EmptySet, ::Int)
return error("the upper bound of an empty set is undefined")
throw(ArgumentError("the upper bound of an empty set is undefined"))
end
21 changes: 0 additions & 21 deletions src/Sets/EmptySet/in.jl
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
"""
∈(x::AbstractVector, ∅::EmptySet)
Check whether a given point is contained in an empty set.
### Input
- `x` -- point/vector
- `∅` -- empty set
### Output
`false`.
### Examples
```jldoctest
julia> [1.0, 0.0] ∈ ∅(2)
false
```
"""
function (::AbstractVector, ::EmptySet)
return false
end
13 changes: 0 additions & 13 deletions src/Sets/EmptySet/isbounded.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
"""
isbounded(∅::EmptySet)
Check whether an empty set is bounded.
### Input
- `∅` -- empty set
### Output
`true`.
"""
function isbounded(::EmptySet)
return true
end
13 changes: 0 additions & 13 deletions src/Sets/EmptySet/isempty.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
"""
isempty(∅::EmptySet)
Check if the empty set is empty.
### Input
- `∅` -- empty set
### Output
`true`.
"""
function isempty(::EmptySet)
return true
end
15 changes: 0 additions & 15 deletions src/Sets/EmptySet/isuniversal.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
"""
isuniversal(∅::EmptySet{N}, [witness]::Bool=false) where {N}
Check whether an empty set is universal.
### Input
- `∅` -- empty set
- `witness` -- (optional, default: `false`) compute a witness if activated
### Output
* If `witness` option is deactivated: `false`
* If `witness` option is activated: `(false, v)` where ``v ∉ S``
"""
function isuniversal(∅::EmptySet{N}, witness::Bool=false) where {N}
if witness
return (false, zeros(N, dim(∅)))
Expand Down
16 changes: 1 addition & 15 deletions src/Sets/EmptySet/linear_map.jl
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
"""
linear_map(M::AbstractMatrix{N}, ∅::EmptySet{N}) where {N}
Return the linear map of an empty set.
### Input
- `M` -- matrix
- `∅` -- empty set
### Output
An empty set.
"""
function linear_map(M::AbstractMatrix, ∅::EmptySet)
N = eltype(∅)
@assert size(M, 2) == dim(∅) "cannot apply a $(size(M))-dimensional " *
"matrix to a $(dim(∅))-dimensional set"

N = eltype(∅)
return EmptySet{N}(size(M, 1))
end
36 changes: 2 additions & 34 deletions src/Sets/EmptySet/low.jl
Original file line number Diff line number Diff line change
@@ -1,39 +1,7 @@
"""
low(∅::EmptySet)
Return a vector with the lowest coordinates of an empty set in each canonical
direction.
### Input
- `∅` -- empty set
### Output
An error.
### Notes
See also [`low(∅::EmptySet, i::Int)`](@ref).
"""
function low(::EmptySet)
return error("the lower bound of an empty set is undefined")
throw(ArgumentError("the lower bound of an empty set is undefined"))
end

"""
low(∅::EmptySet, i::Int)
Return the lowest coordinate of an empty set in the given direction.
### Input
- `∅` -- empty set
- `i` -- dimension of interest
### Output
An error.
"""
function low(::EmptySet, ::Int)
return error("the lower bound of an empty set is undefined")
throw(ArgumentError("the lower bound of an empty set is undefined"))
end
18 changes: 1 addition & 17 deletions src/Sets/EmptySet/norm.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
"""
norm(∅::EmptySet, [p]::Real=Inf)
Return the norm of an empty set.
It is the norm of the enclosing ball (of the given ``p``-norm) of minimal volume
that is centered in the origin.
### Input
- `∅` -- empty set
- `p` -- (optional, default: `Inf`) norm
### Output
An error.
"""
function norm(::EmptySet, ::Real=Inf)
return error("the norm of an empty set is undefined")
throw(ArgumentError("the norm of an empty set is undefined"))
end
18 changes: 1 addition & 17 deletions src/Sets/EmptySet/radius.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
"""
radius(∅::EmptySet, [p]::Real=Inf)
Return the radius of an empty set.
It is the radius of the enclosing ball (of the given ``p``-norm) of minimal
volume with the same center.
### Input
- `∅` -- empty set
- `p` -- (optional, default: `Inf`) norm
### Output
An error.
"""
function radius(::EmptySet, ::Real=Inf)
return error("the radius of an empty set is undefined")
throw(ArgumentError("the radius of an empty set is undefined"))
end
14 changes: 3 additions & 11 deletions src/Sets/EmptySet/rand.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
"""
# Extended help
rand(::Type{EmptySet}; [N]::Type{<:Real}=Float64, [dim]::Int=2,
[rng]::AbstractRNG=GLOBAL_RNG, [seed]::Union{Int, Nothing}=nothing)
Create an empty set (note that there is nothing to randomize).
### Input
- `EmptySet` -- type for dispatch
- `N` -- (optional, default: `Float64`) numeric type
- `dim` -- (optional, default: 2) dimension
- `rng` -- (optional, default: `GLOBAL_RNG`) random number generator
- `seed` -- (optional, default: `nothing`) seed for reseeding
### Output
The (only) empty set of the given numeric type and dimension.
The (unique) empty set of the given numeric type and dimension.
"""
function rand(::Type{EmptySet};
N::Type{<:Real}=Float64,
Expand Down
13 changes: 0 additions & 13 deletions src/Sets/EmptySet/rectify.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
"""
rectify(∅::EmptySet)
Concrete rectification of an empty set.
### Input
- `∅` -- empty set
### Output
The empty set.
"""
function rectify(∅::EmptySet)
return
end
Loading

0 comments on commit 94a7e6c

Please sign in to comment.