Skip to content

Commit

Permalink
Merge pull request #3627 from JuliaReach/schillic/rename_is
Browse files Browse the repository at this point in the history
Rename functions with `is_` consistently
  • Loading branch information
schillic authored Aug 19, 2024
2 parents 4e0ba3c + 5f465e7 commit 07ce00a
Show file tree
Hide file tree
Showing 90 changed files with 242 additions and 242 deletions.
2 changes: 1 addition & 1 deletion docs/src/lib/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extrema(::LazySet, ::Int)
extrema(::LazySet)
high(::LazySet, ::Int)
high(::LazySet)
is_polyhedral(::LazySet)
ispolyhedral(::LazySet)
isbounded(::LazySet)
isboundedtype(::Type{<:LazySet})
isconvextype(::Type{<:LazySet})
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lib/interfaces/AbstractPolyhedron.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Some common functions implemented by several subtypes:

```@docs
addconstraint!(::AbstractPolyhedron, ::HalfSpace)
is_hyperplanar(::AbstractPolyhedron)
ishyperplanar(::AbstractPolyhedron)
```

Some common functions to work with linear constraints:
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lib/interfaces/LazySet.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ triangulate(::LazySet)
isboundedtype(::Type{<:LazySet})
isbounded(::LazySet)
_isbounded_unit_dimensions(::LazySet)
is_polyhedral(::LazySet)
ispolyhedral(::LazySet)
isfeasible
norm(::LazySet, ::Real=Inf)
radius(::LazySet, ::Real=Inf)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lib/lazy_operations/Bloating.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ isempty(::Bloating)
an_element(::Bloating)
constraints_list(::Bloating)
center(::Bloating)
is_polyhedral(::Bloating)
ispolyhedral(::Bloating)
```
Inherited from [`LazySet`](@ref):
* [`high`](@ref high(::LazySet))
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lib/sets/Ball1.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Inherited from [`LazySet`](@ref):
* [`minkowski_difference`](@ref minkowski_difference(::LazySet, ::LazySet))

Inherited from [`AbstractPolyhedron`](@ref):
* [`is_polyhedral`](@ref is_polyhedral(::AbstractPolyhedron))
* [`ispolyhedral`](@ref ispolyhedral(::AbstractPolyhedron))
* [`intersection`](@ref intersection(::AbstractPolyhedron, ::AbstractPolyhedron))
* [`isdisjoint`](@ref isdisjoint(::AbstractPolyhedron, ::AbstractPolyhedron))
* [``](@ref ⊆(::AbstractPolyhedron, ::AbstractPolyhedron))
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lib/sets/Ball2.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Inherited from [`LazySet`](@ref):
* [`eltype`](@ref eltype(::Type{<:LazySet}))
* [`eltype`](@ref eltype(::LazySet))
* [`high`](@ref high(::LazySet))
* [`is_polyhedral`](@ref is_polyhedral(::LazySet))
* [`ispolyhedral`](@ref ispolyhedral(::LazySet))
* [`low`](@ref low(::LazySet))
* [`norm`](@ref norm(::LazySet, ::Real))
* [`radius`](@ref radius(::LazySet, ::Real))
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lib/sets/BallInf.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Inherited from [`LazySet`](@ref):
* [`linear_combination`](@ref linear_combination(::ConvexSet, ::ConvexSet))

Inherited from [`AbstractPolyhedron`](@ref):
* [`is_polyhedral`](@ref is_polyhedral(::AbstractPolyhedron))
* [`ispolyhedral`](@ref ispolyhedral(::AbstractPolyhedron))

Inherited from [`AbstractPolytope`](@ref):
* [`isbounded`](@ref isbounded(::AbstractPolytope))
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lib/sets/Ballp.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Inherited from [`LazySet`](@ref):
* [`eltype`](@ref eltype(::LazySet))
* [`high`](@ref high(::LazySet))
* [`low`](@ref low(::LazySet))
* [`is_polyhedral`](@ref is_polyhedral(::LazySet))
* [`ispolyhedral`](@ref ispolyhedral(::LazySet))
* [`isoperation`](@ref isoperation(::LazySet))
* [`norm`](@ref norm(::LazySet, ::Real))
* [`radius`](@ref radius(::LazySet, ::Real))
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lib/sets/Ellipsoid.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Inherited from [`LazySet`](@ref):
* [`eltype`](@ref eltype(::Type{<:LazySet}))
* [`eltype`](@ref eltype(::LazySet))
* [`high`](@ref high(::LazySet))
* [`is_polyhedral`](@ref is_polyhedral(::LazySet))
* [`ispolyhedral`](@ref ispolyhedral(::LazySet))
* [`isoperation`](@ref isoperation(::LazySet))
* [`low`](@ref low(::LazySet))
* [`norm`](@ref norm(::LazySet, ::Real))
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lib/sets/EmptySet.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Inherited from [`LazySet`](@ref):
* [`extrema`](@ref extrema(::LazySet))
* [`extrema`](@ref extrema(::LazySet, ::Int))
* [`isoperation`](@ref isoperation(::LazySet))
* [`is_polyhedral`](@ref is_polyhedral(::LazySet))
* [`ispolyhedral`](@ref ispolyhedral(::LazySet))
* [`singleton_list`](@ref singleton_list(::LazySet))
* [`surface`](@ref surface(::LazySet))
* [`cartesian_product`](@ref cartesian_product(::LazySet, ::LazySet))
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lib/sets/Interval.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Inherited from [`LazySet`](@ref):
* [`==`](@ref ==(::LazySet, ::LazySet))

Inherited from [`AbstractPolyhedron`](@ref):
* [`is_polyhedral`](@ref is_polyhedral(::AbstractPolyhedron))
* [`ispolyhedral`](@ref ispolyhedral(::AbstractPolyhedron))

Inherited from [`ConvexSet`](@ref):
```@meta
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lib/sets/LineSegment.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Inherited from [`ConvexSet`](@ref):
* [`linear_combination`](@ref linear_combination(::ConvexSet, ::ConvexSet))

Inherited from [`AbstractPolyhedron`](@ref):
* [`is_polyhedral`](@ref is_polyhedral(::AbstractPolyhedron))
* [`ispolyhedral`](@ref ispolyhedral(::AbstractPolyhedron))

Inherited from [`AbstractPolytope`](@ref):
* [`isbounded`](@ref isbounded(::AbstractPolytope))
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lib/sets/Singleton.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Inherited from [`ConvexSet`](@ref):
* [`linear_combination`](@ref linear_combination(::ConvexSet, ::ConvexSet))

Inherited from [`AbstractPolyhedron`](@ref):
* [`is_polyhedral`](@ref is_polyhedral(::AbstractPolyhedron))
* [`ispolyhedral`](@ref ispolyhedral(::AbstractPolyhedron))

Inherited from [`AbstractPolytope`](@ref):
* [`isbounded`](@ref isbounded(::AbstractPolytope))
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lib/sets/ZeroSet.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Inherited from [`ConvexSet`](@ref):
* [`linear_combination`](@ref linear_combination(::ConvexSet, ::ConvexSet))

Inherited from [`AbstractPolyhedron`](@ref):
* [`is_polyhedral`](@ref is_polyhedral(::AbstractPolyhedron))
* [`ispolyhedral`](@ref ispolyhedral(::AbstractPolyhedron))

Inherited from [`AbstractPolytope`](@ref):
* [`isbounded`](@ref isbounded(::AbstractPolytope))
Expand Down
6 changes: 3 additions & 3 deletions docs/src/lib/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ LazySets._vec

```@docs
LazySets.free_symbols
LazySets._is_linearcombination
LazySets._is_halfspace
LazySets._is_hyperplane
LazySets._is_linear_combination
LazySets._ishalfspace
LazySets._ishyperplanar
LazySets.convert(::Type{HalfSpace{N}}, ::Expr; vars::Vector{Basic}=Basic[]) where {N}
LazySets.convert(::Type{Hyperplane{N}}, ::Expr; vars::Vector{Basic}=Basic[]) where {N}
```
Expand Down
4 changes: 2 additions & 2 deletions src/API/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ReachabilityBase.Arrays: distance, rectify
export
# unary set operations
an_element, area, center, complement, concretize, constraints_list,
constraints, convex_hull, diameter, dim, high, is_polyhedral, isbounded,
constraints, convex_hull, diameter, dim, high, ispolyhedral, isbounded,
isboundedtype, isconvextype, isoperation, isoperationtype, isuniversal,
low, norm, radius, rectify, reflect, surface, vertices_list, vertices,
volume,
Expand Down Expand Up @@ -44,7 +44,7 @@ include("Unary/dim.jl")
include("Unary/eltype.jl")
include("Unary/extrema.jl")
include("Unary/high.jl")
include("Unary/is_polyhedral.jl")
include("Unary/ispolyhedral.jl")
include("Unary/isbounded.jl")
include("Unary/isboundedtype.jl")
include("Unary/isconvextype.jl")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
is_polyhedral(X::LazySet)
ispolyhedral(X::LazySet)
Check whether a set is polyhedral.
Expand All @@ -16,4 +16,4 @@ Check whether a set is polyhedral.
The answer is conservative, i.e., may sometimes be `false` even if the set is
polyhedral.
"""
function is_polyhedral(::LazySet) end
function ispolyhedral(::LazySet) end
2 changes: 1 addition & 1 deletion src/Approximations/init_Ipopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function default_nln_solver(N::Type{<:Real}=Float64)
end

function _underapproximate_box(X::S, solver) where {S<:LazySet}
if !isconvextype(S) || !(is_polyhedral(X) && isboundedtype(S))
if !isconvextype(S) || !(ispolyhedral(X) && isboundedtype(S))
error("box underapproximation is only available for convex polytopes")
end

Expand Down
4 changes: 2 additions & 2 deletions src/ConcreteOperations/isdisjoint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ function _isdisjoint_polyhedron(P::AbstractPolyhedron, X::LazySet,
return false
elseif algorithm == "exact"
# exact check for empty intersection using a feasibility LP
if !is_polyhedral(X)
if !ispolyhedral(X)
error("this algorithm requires a polyhedral input")
end
clist_P = _normal_Vector(P) # TODO
Expand Down Expand Up @@ -936,7 +936,7 @@ end

function _isdisjoint_cpa_polyhedron(cpa::CartesianProductArray, P, witness)
cpa_low_dim, vars, _block_structure = get_constrained_lowdimset(cpa, P)
if !is_polyhedral(cpa_low_dim)
if !ispolyhedral(cpa_low_dim)
error("a polyhedral set is required")
end
T = isconvextype(typeof(cpa_low_dim)) ? HPolytope : HPolyhedron
Expand Down
6 changes: 3 additions & 3 deletions src/ConcreteOperations/issubset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The default implementation assumes that `Y` is polyhedral, i.e., that
constraint of `Y`.
"""
function (X::LazySet, Y::LazySet, witness::Bool=false)
if is_polyhedral(Y)
if ispolyhedral(Y)
return _issubset_constraints_list(X, Y, witness)
else
throw(ArgumentError("an inclusion check for the given combination of " *
Expand Down Expand Up @@ -181,7 +181,7 @@ function ⊆(P::AbstractPolytope, S::LazySet, witness::Bool=false;

if isnothing(algorithm)
# TODO smarter evaluation which representation is better
if is_polyhedral(S)
if ispolyhedral(S)
algorithm = "constraints"
else
algorithm = "vertices"
Expand Down Expand Up @@ -296,7 +296,7 @@ end
# ⊆(X::LazySet, P::AbstractPolyhedron, witness::Bool=false)
function _issubset_constraints_list(S::LazySet, P::LazySet, witness::Bool=false)
@assert dim(S) == dim(P) "incompatible set dimensions $(dim(S)) and $(dim(P))"
@assert is_polyhedral(P) "this inclusion check requires a polyhedral set " *
@assert ispolyhedral(P) "this inclusion check requires a polyhedral set " *
"on the right-hand side"

@inbounds for H in constraints_list(P)
Expand Down
2 changes: 1 addition & 1 deletion src/ConcreteOperations/minkowski_difference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ of disturbance invariant sets for discrete-time linear systems.*
317-367.](http://dx.doi.org/10.1155/S1024123X98000866)
"""
function minkowski_difference(P::LazySet, Q::LazySet)
@assert is_polyhedral(P) "this implementation requires that the first argument " *
@assert ispolyhedral(P) "this implementation requires that the first argument " *
"is polyhedral; try overapproximating with an `HPolyhedron`"
@assert isbounded(Q) "this implementation requires that the second " *
"argument is bounded, but it is not"
Expand Down
2 changes: 1 addition & 1 deletion src/ConcreteOperations/minkowski_sum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function minkowski_sum(P::LazySet, Q::LazySet;
@assert n == dim(Q) "expected that the sets have the same dimension, " *
"but they are $n and $(dim(Q)) respectively"

@assert is_polyhedral(P) && is_polyhedral(Q) "this function requires " *
@assert ispolyhedral(P) && ispolyhedral(Q) "this function requires " *
"polyhedral sets; try overapproximating with an `HPolytope` or " *
"`HPolyhedron` first"

Expand Down
20 changes: 10 additions & 10 deletions src/Initialization/init_SymEngine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using .SymEngine: Basic
import .SymEngine: free_symbols

"""
_is_linearcombination(L::Basic)
_is_linear_combination(L::Basic)
Determine whether the expression `L` is a linear combination of its symbols.
Expand All @@ -17,26 +17,26 @@ Determine whether the expression `L` is a linear combination of its symbols.
### Examples
```jldoctest
julia> using LazySets: _is_linearcombination
julia> using LazySets: _is_linear_combination
julia> _is_linearcombination(:(2*x1 - 4))
julia> _is_linear_combination(:(2*x1 - 4))
true
julia> _is_linearcombination(:(6.1 - 5.3*f - 0.1*g))
julia> _is_linear_combination(:(6.1 - 5.3*f - 0.1*g))
true
julia> _is_linearcombination(:(2*x1^2))
julia> _is_linear_combination(:(2*x1^2))
false
julia> _is_linearcombination(:(x1^2 - 4*x2 + x3 + 2))
julia> _is_linear_combination(:(x1^2 - 4*x2 + x3 + 2))
false
```
"""
function _is_linearcombination(L::Basic)
function _is_linear_combination(L::Basic)
return all(isempty.(free_symbols.(diff.(L, SymEngine.free_symbols(L)))))
end

_is_linearcombination(L::Expr) = _is_linearcombination(convert(Basic, L))
_is_linear_combination(L::Expr) = _is_linear_combination(convert(Basic, L))

"""
free_symbols(expr::Expr, set_type::Type{LazySet})
Expand Down Expand Up @@ -86,9 +86,9 @@ end

# Note: this convenience function is not used anywhere
function _free_symbols(expr::Expr)
if _is_hyperplane(expr)
if _ishyperplanar(expr)
return free_symbols(expr, Hyperplane)
elseif _is_halfspace(expr)
elseif _ishalfspace(expr)
return free_symbols(expr, HalfSpace)
else
error("the `free_symbols` method for the expression $expr is not implemented")
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/AbstractAffineMap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function set(::AbstractAffineMap) end

isoperationtype(::Type{<:AbstractAffineMap}) = true
isconvextype(::Type{<:AbstractAffineMap{N,S}}) where {N,S} = isconvextype(S)
is_polyhedral(am::AbstractAffineMap) = is_polyhedral(set(am))
ispolyhedral(am::AbstractAffineMap) = ispolyhedral(set(am))

"""
dim(am::AbstractAffineMap)
Expand Down
4 changes: 2 additions & 2 deletions src/Interfaces/AbstractPolyhedron.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ function _linear_map_hrep_helper(M::AbstractMatrix, P::LazySet,
end

# internal functions; defined here due to dependency SymEngine and submodules
function _is_halfspace end
function _is_hyperplane end
function _ishalfspace end
function _ishyperplanar end
function _parse_linear_expression end

# To account for the compilation order, other functions are defined in the file
Expand Down
8 changes: 4 additions & 4 deletions src/Interfaces/AbstractPolyhedron_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ export constrained_dimensions,
remove_redundant_constraints!,
isfeasible,
addconstraint!,
is_hyperplanar
ishyperplanar

isconvextype(::Type{<:AbstractPolyhedron}) = true

is_polyhedral(::AbstractPolyhedron) = true
ispolyhedral(::AbstractPolyhedron) = true

"""
constraints_list(A::AbstractMatrix{N}, b::AbstractVector)
Expand Down Expand Up @@ -1235,7 +1235,7 @@ is the same.
function addconstraint!(::AbstractPolyhedron, ::HalfSpace) end

"""
is_hyperplanar(P::AbstractPolyhedron)
ishyperplanar(P::AbstractPolyhedron)
Determine whether a polyhedron is equivalent to a hyperplane.
Expand All @@ -1248,4 +1248,4 @@ Determine whether a polyhedron is equivalent to a hyperplane.
`true` iff `P` is hyperplanar, i.e., consists of two linear constraints
``a·x ≤ b`` and ``-a·x ≤ -b``.
"""
function is_hyperplanar(::AbstractPolyhedron) end
function ishyperplanar(::AbstractPolyhedron) end
Loading

0 comments on commit 07ce00a

Please sign in to comment.