Skip to content

Commit

Permalink
resolve submodule dependencies via Requires
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Jul 19, 2024
1 parent 224764e commit f898397
Show file tree
Hide file tree
Showing 77 changed files with 207 additions and 70 deletions.
13 changes: 8 additions & 5 deletions src/Sets/Ball1/Ball1Module.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
module Ball1Module

using Reexport
using Reexport, Requires

using ..LazySets: AbstractCentrallySymmetricPolytope, HalfSpace
using ..LazySets: AbstractCentrallySymmetricPolytope, _high_AbstractBallp,
_low_AbstractBallp
using LinearAlgebra: dot
using Random: AbstractRNG, GLOBAL_RNG
using ReachabilityBase.Distribution: reseed!
using ReachabilityBase.Arrays: argmaxabs
using LinearAlgebra: dot
using ReachabilityBase.Distribution: reseed!
using ReachabilityBase.Require: require

@reexport import ..API: center, constraints_list, high, isoperationtype, low,
rand, reflect, vertices_list, , project, scale, ρ, σ,
translate!
@reexport import ..LazySets: ball_norm, radius_ball
@reexport using ..API
using ..LazySets: _high_AbstractBallp, _low_AbstractBallp

export Ball1

Expand All @@ -36,4 +37,6 @@ include("support_vector.jl")
include("translate.jl")
include("vertices_list.jl")

include("init.jl")

end # module
2 changes: 2 additions & 0 deletions src/Sets/Ball1/constraints_list.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ The constraints can be defined as ``d_i^T (x-c) ≤ r`` for all ``d_i``, where
all possible ``d_i``, the function `Iterators.product` is used.
"""
function constraints_list(B::Ball1)
require(@__MODULE__, :LazySets; fun_name="constraints_list")

n = dim(B)
c, r = B.center, B.radius
N = eltype(B)
Expand Down
3 changes: 3 additions & 0 deletions src/Sets/Ball1/init.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function __init__()
@require LazySets = "b4f0291d-fe17-52bc-9479-3d1a343d9043" include("init_LazySets.jl")
end
1 change: 1 addition & 0 deletions src/Sets/Ball1/init_LazySets.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
using .LazySets.HalfSpaceModule: HalfSpace
2 changes: 1 addition & 1 deletion src/Sets/Ball2/Ball2Module.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module Ball2Module
using Reexport, Requires

using ..LazySets: AbstractBallp, _witness_result_empty
using LinearAlgebra: dot, axpby!
using Random: AbstractRNG, GLOBAL_RNG
using ReachabilityBase.Comparison: _leq, isapproxzero
using ReachabilityBase.Distribution: reseed!
using ReachabilityBase.Require
using LinearAlgebra: dot, axpby!

@reexport import ..API: area, center, isoperationtype, rand, reflect, sample,
volume, , project, scale, ρ, σ, translate!,
Expand Down
2 changes: 1 addition & 1 deletion src/Sets/BallInf/BallInfModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ using Reexport, Requires

using ..LazySets: AbstractHyperrectangle, _high_AbstractBallp, _low_AbstractBallp,
_ρ_sev_hyperrectangle, _σ_sev_hyperrectangle
using LinearAlgebra: dot
using Random: AbstractRNG, GLOBAL_RNG
using ReachabilityBase.Arrays: SingleEntryVector
using ReachabilityBase.Comparison: isapproxzero
using ReachabilityBase.Distribution: reseed!
using LinearAlgebra: dot

@reexport import ..API: area, center, isoperationtype, high, low, radius, rand,
reflect, volume, project, scale, ρ, σ, translate!
Expand Down
6 changes: 6 additions & 0 deletions src/Sets/Ballp/Ballp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,16 @@ struct Ballp{N<:AbstractFloat,VN<:AbstractVector{N}} <: AbstractBallp{N}
@assert radius >= zero(N) "the radius must not be negative"
@assert p >= one(N) "p must not be less than 1"
if p == N(Inf)
require(@__MODULE__, :LazySets; fun_name="Ballp")

return BallInf(center, radius)
elseif p == N(2)
require(@__MODULE__, :LazySets; fun_name="Ballp")

return Ball2(center, radius)
elseif isone(p)
require(@__MODULE__, :LazySets; fun_name="Ballp")

return Ball1(center, radius)
else
return new{N,VN}(p, center, radius)
Expand Down
7 changes: 5 additions & 2 deletions src/Sets/Ballp/BallpModule.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
module BallpModule

using Reexport
using Reexport, Requires

using ..LazySets: AbstractBallp, Ball1, Ball2, BallInf
using ..LazySets: AbstractBallp
using Random: AbstractRNG, GLOBAL_RNG
using ReachabilityBase.Distribution: reseed!
using ReachabilityBase.Require: require

@reexport import ..API: center, isoperationtype, rand, reflect, project, scale,
translate!
Expand All @@ -25,4 +26,6 @@ include("reflect.jl")
include("scale.jl")
include("translate.jl")

include("init.jl")

end # module
3 changes: 3 additions & 0 deletions src/Sets/Ballp/init.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function __init__()
@require LazySets = "b4f0291d-fe17-52bc-9479-3d1a343d9043" include("init_LazySets.jl")
end
3 changes: 3 additions & 0 deletions src/Sets/Ballp/init_LazySets.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using .LazySets.Ball1Module: Ball1
using .LazySets.Ball2Module: Ball2
using .LazySets.BallInfModule: BallInf
4 changes: 2 additions & 2 deletions src/Sets/Ellipsoid/EllipsoidModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module EllipsoidModule
using Reexport

using ..LazySets: AbstractCentrallySymmetric
using LinearAlgebra: dot, I, checksquare, isposdef
using Random: AbstractRNG, GLOBAL_RNG
using ReachabilityBase.Distribution: reseed!
using ReachabilityBase.Arrays: inner
using LinearAlgebra: dot, I, checksquare, isposdef
using ReachabilityBase.Distribution: reseed!

@reexport import ..API: center, isoperationtype, rand, affine_map, ,
linear_map, ρ, σ, translate!
Expand Down
10 changes: 6 additions & 4 deletions src/Sets/EmptySet/EmptySetModule.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
module EmptySetModule

using Reexport
using Reexport, Requires

using ..LazySets: LazySet, ConvexSet, Universe, _witness_result_empty
using ..LazySets: LazySet, ConvexSet, _witness_result_empty
using Random: AbstractRNG, GLOBAL_RNG
using ReachabilityBase.Distribution: reseed!
using ReachabilityBase.Iteration: EmptyIterator
using ReachabilityBase.Require: require

@reexport import ..API: an_element, area, complement, diameter, dim, high, ,
isbounded, isboundedtype, isconvextype, isempty,
isoperationtype, isuniversal, linear_map, low, norm,
project, radius, rand, rectify, reflect, scale, scale!,
ρ, σ, translate, translate!, vertices, vertices_list,
volume,
convex_hull, intersection, isdisjoint,
volume, convex_hull, intersection, isdisjoint,
@reexport import ..LazySets: chebyshev_center_radius, plot_recipe
@reexport using ..API

Expand Down Expand Up @@ -75,4 +75,6 @@ function plot_recipe(::EmptySet{N}, ε=zero(N)) where {N}
return []
end

include("init.jl")

end # module
2 changes: 2 additions & 0 deletions src/Sets/EmptySet/complement.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ Return the complement of an empty set.
The universe of the same dimension.
"""
function complement(∅::EmptySet{N}) where {N}
require(@__MODULE__, :LazySets; fun_name="complement")

return Universe{N}(dim(∅))
end
3 changes: 3 additions & 0 deletions src/Sets/EmptySet/init.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function __init__()
@require LazySets = "b4f0291d-fe17-52bc-9479-3d1a343d9043" include("init_LazySets.jl")
end
1 change: 1 addition & 0 deletions src/Sets/EmptySet/init_LazySets.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
using .LazySets.UniverseModule: Universe
2 changes: 2 additions & 0 deletions src/Sets/HParallelotope/HParallelotope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ struct HParallelotope{N,VN<:AbstractVector{N},MN<:AbstractMatrix{N}} <: Abstract
"but they have sizes $(length(c)) and $(size(D)) respectively"

if check_consistency
require(@__MODULE__, :LazySets; fun_name="HParallelotope")

P = HPolyhedron(_constraints_list_hparallelotope(D, c, N, VN))
if isempty(P)
throw(ArgumentError("the constraints are contradictory"))
Expand Down
9 changes: 6 additions & 3 deletions src/Sets/HParallelotope/HParallelotopeModule.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
module HParallelotopeModule

using Reexport
using Reexport, Requires

using ..LazySets: AbstractZonotope, HalfSpace, HPolyhedron, generators_fallback
using ..LazySets: AbstractZonotope, HalfSpace, generators_fallback
using LinearAlgebra: checksquare, det
using Random: AbstractRNG, GLOBAL_RNG
using ReachabilityBase.Arrays: to_negative_vector
using ReachabilityBase.Distribution: reseed!
using LinearAlgebra: checksquare, det
using ReachabilityBase.Require: require

@reexport import ..API: center, constraints_list, dim, isoperationtype, rand,
volume
Expand Down Expand Up @@ -34,4 +35,6 @@ include("offset.jl")
include("rand.jl")
include("volume.jl")

include("init.jl")

end # module
3 changes: 3 additions & 0 deletions src/Sets/HParallelotope/init.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function __init__()
@require LazySets = "b4f0291d-fe17-52bc-9479-3d1a343d9043" include("init_LazySets.jl")
end
1 change: 1 addition & 0 deletions src/Sets/HParallelotope/init_LazySets.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
using .LazySets.HPolyhedronModule: HPolyhedron
2 changes: 2 additions & 0 deletions src/Sets/HParallelotope/rand.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function rand(::Type{HParallelotope};
dim::Int=2,
rng::AbstractRNG=GLOBAL_RNG,
seed::Union{Int,Nothing}=nothing)
require(@__MODULE__, :LazySets; fun_name="rand")

rng = reseed!(rng, seed)

while true
Expand Down
2 changes: 1 addition & 1 deletion src/Sets/HPolygon/HPolygonModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Reexport
using ..LazySets: AbstractHPolygon, BINARY_SEARCH_THRESHOLD, addconstraint!,
binary_search_constraints, constraints_list, element,
isbounded, , _intersection_line2d
using ..LazySets.HalfSpaceModule: HalfSpace, _normal_Vector
using ..HalfSpaceModule: HalfSpace, _normal_Vector

@reexport import ..API: isoperationtype, σ, translate
@reexport using ..API
Expand Down
5 changes: 3 additions & 2 deletions src/Sets/HPolyhedron/HPolyhedronModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ module HPolyhedronModule

using Reexport, Requires

using ..LazySets: AbstractPolyhedron, HalfSpace, default_lp_solver,
using ..LazySets: AbstractPolyhedron, default_lp_solver,
default_polyhedra_backend, iscomplement, is_lp_infeasible,
is_lp_optimal, is_lp_unbounded, has_lp_infeasibility_ray,
linprog, tosimplehrep, _isempty_polyhedron, _normal_Vector
using ..HalfSpaceModule: HalfSpace
using ..HPolytopeModule: HPolytope
using LinearAlgebra: dot
using Random: AbstractRNG, GLOBAL_RNG
using ReachabilityBase.Arrays: to_negative_vector
using ReachabilityBase.Basetype: basetype
using ReachabilityBase.Comparison: isapproxzero
using ReachabilityBase.Distribution: reseed!
using ReachabilityBase.Require: require
using LinearAlgebra: dot

@reexport import ..API: constraints_list, dim, isempty, isoperationtype, rand,
permute, ρ, σ, translate
Expand Down
7 changes: 4 additions & 3 deletions src/Sets/HPolytope/HPolytopeModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ module HPolytopeModule

using Reexport, Requires

using ..LazySets: AbstractPolytope, HalfSpace, HPolygon,
AbstractLinearMapAlgorithm, default_polyhedra_backend,
vertices_list_1d, _linear_map_hrep, _normal_Vector
using ..LazySets: AbstractPolytope, AbstractLinearMapAlgorithm,
default_polyhedra_backend, vertices_list_1d, _linear_map_hrep,
_normal_Vector
using ..HalfSpaceModule: HalfSpace
using Random: AbstractRNG, GLOBAL_RNG
using ReachabilityBase.Distribution: reseed!
using ReachabilityBase.Comparison: isapproxzero, _ztol
Expand Down
1 change: 1 addition & 0 deletions src/Sets/HPolytope/init_LazySets.jl
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
using .LazySets.HPolygonModule: HPolygon
using .LazySets.VPolytopeModule: VPolytope
2 changes: 2 additions & 0 deletions src/Sets/HPolytope/vertices_list.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ function vertices_list(P::HPolytope; backend=nothing, prune::Bool=true)
if n == 1
return vertices_list_1d(P)
elseif n == 2
require(@__MODULE__, :LazySets; fun_name="vertices_list")

return vertices_list(convert(HPolygon, P; prune=prune))
end
end
Expand Down
8 changes: 4 additions & 4 deletions src/Sets/HalfSpace/HalfSpaceModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ module HalfSpaceModule

using Reexport, Requires

using ..LazySets: AbstractPolyhedron, LazySet, AbstractLinearMapAlgorithm,
@commutative
using ..LazySets: AbstractPolyhedron, LazySet, AbstractLinearMapAlgorithm
import LinearAlgebra
using LinearAlgebra: dot
using Random: AbstractRNG, GLOBAL_RNG
using ReachabilityBase.Arrays: ismultiple, nonzero_indices, samedir
using ReachabilityBase.Commutative: @commutative
using ReachabilityBase.Comparison: isapproxzero, _isapprox, _leq
using ReachabilityBase.Distribution: reseed!
using ReachabilityBase.Require: require
import LinearAlgebra
using LinearAlgebra: dot

@reexport import ..API: an_element, complement, constraints_list, dim,
isbounded, isempty, isoperationtype, isuniversal, rand,
Expand Down
8 changes: 4 additions & 4 deletions src/Sets/Hyperplane/HyperplaneModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ module HyperplaneModule

using Reexport, Requires

using ..LazySets: AbstractPolyhedron, HalfSpace, AbstractLinearMapAlgorithm,
@commutative, _linear_map_hrep, _non_element_halfspace,
_normalize_halfspace
using ..LazySets: AbstractPolyhedron, AbstractLinearMapAlgorithm,
_linear_map_hrep, _non_element_halfspace, _normalize_halfspace
using LinearAlgebra: dot
using Random: AbstractRNG, GLOBAL_RNG
using ReachabilityBase.Arrays: nonzero_indices
using ReachabilityBase.Commutative: @commutative
using ReachabilityBase.Comparison: _isapprox
using ReachabilityBase.Distribution: reseed!
using ReachabilityBase.Require: require
using LinearAlgebra: dot

@reexport import ..API: an_element, constraints_list, dim, isbounded, isempty,
isoperationtype, isuniversal, rand, reflect, distance,
Expand Down
2 changes: 2 additions & 0 deletions src/Sets/Hyperplane/constraints_list.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ end

# internal helper function
function _constraints_list_hyperplane(a::AbstractVector, b)
require(@__MODULE__, :LazySets; fun_name="constraints_list")

return [HalfSpace(a, b), HalfSpace(-a, -b)]
end
1 change: 1 addition & 0 deletions src/Sets/Hyperplane/init_LazySets.jl
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
using .LazySets.HalfSpaceModule: HalfSpace
using .LazySets.UniverseModule: Universe
14 changes: 8 additions & 6 deletions src/Sets/Interval/IntervalModule.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module IntervalModule

using Reexport
using Reexport, Requires

using ..LazySets: AbstractHyperrectangle, LazySet, HalfSpace, Zonotope, UnionSet,
using ..LazySets: AbstractHyperrectangle, LazySet, UnionSet,
_witness_result_empty
using ..LazySets.EmptySetModule: EmptySet
using ..API: eltype, isconvextype, isempty
import IntervalArithmetic as IA
using Random: AbstractRNG, GLOBAL_RNG
using ReachabilityBase.Arrays
using ReachabilityBase.Comparison
using ReachabilityBase.Arrays: SingleEntryVector
using ReachabilityBase.Comparison: isapproxzero, _isapprox, _leq
using ReachabilityBase.Distribution: reseed!
import IntervalArithmetic as IA
using ReachabilityBase.Require: require

@reexport import ..API: affine_map, an_element, center, complement, constraints_list,
convex_hull, diameter, dim, exponential_map, extrema, high, ,
Expand Down Expand Up @@ -167,4 +167,6 @@ function plot_recipe(x::Interval{N}, ε=zero(N)) where {N}
return [min(x), max(x)], zeros(N, 2)
end

include("init.jl")

end # module
2 changes: 2 additions & 0 deletions src/Sets/Interval/complement.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
function complement(X::Interval)
require(@__MODULE__, :LazySets; fun_name="complement")

N = eltype(X)
L = HalfSpace(SingleEntryVector(1, 1, one(N)), min(X))
H = HalfSpace(SingleEntryVector(1, 1, -one(N)), -max(X))
Expand Down
2 changes: 2 additions & 0 deletions src/Sets/Interval/constraints_list.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ The list of constraints of the interval represented as two one-dimensional
half-spaces.
"""
function constraints_list(x::Interval)
require(@__MODULE__, :LazySets; fun_name="constraints_list")

N = eltype(x)
constraints = Vector{HalfSpace{N,SingleEntryVector{N}}}(undef, 2)
e₁ = SingleEntryVector(1, 1, one(N))
Expand Down
2 changes: 2 additions & 0 deletions src/Sets/Interval/difference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ function difference(X::Interval{N}, Y::Interval) where {N}
flat_right = isflat(R)

if flat_left && flat_right
require(@__MODULE__, :LazySets; fun_name="difference")

return EmptySet{N}(1)
elseif flat_left && !flat_right
return R
Expand Down
3 changes: 3 additions & 0 deletions src/Sets/Interval/init.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function __init__()
@require LazySets = "b4f0291d-fe17-52bc-9479-3d1a343d9043" include("init_LazySets.jl")
end
3 changes: 3 additions & 0 deletions src/Sets/Interval/init_LazySets.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using .LazySets.EmptySetModule: EmptySet
using .LazySets.HalfSpaceModule: HalfSpace
using .LazySets.ZonotopeModule: Zonotope
Loading

0 comments on commit f898397

Please sign in to comment.