diff --git a/src/Approximations/overapproximate.jl b/src/Approximations/overapproximate.jl index 311b4f3269..b3fbe70ff9 100644 --- a/src/Approximations/overapproximate.jl +++ b/src/Approximations/overapproximate.jl @@ -146,8 +146,6 @@ function overapproximate(X::LazySet{N}, return H end -@require IntervalArithmetic begin - """ overapproximate(::LazySet{N}, ::Type{LazySets.Interval}) where {N<:Real} @@ -168,5 +166,3 @@ function overapproximate(S::LazySet{N}, ::Type{LazySets.Interval}) where {N<:Rea hi = σ([one(N)], S)[1] return LazySets.Interval(lo, hi) end - -end # @require diff --git a/src/HPolytope.jl b/src/HPolytope.jl index ef51c174d5..6f3f1b2315 100644 --- a/src/HPolytope.jl +++ b/src/HPolytope.jl @@ -199,7 +199,8 @@ function tosimplehrep(P::HPolytope{N}) where {N} return (A, b) end -@require Polyhedra begin +function load_polyhedra_hpolytope() # function to be loaded by Requires +return quote using CDDLib # default backend import Polyhedra:polyhedron, SimpleHRepresentation, SimpleHRepresentation, @@ -368,5 +369,5 @@ function vertices_list(P::HPolytope{N}; prunefunc(P) return collect(points(P)) end - -end +end # quote +end # function load_polyhedra_hpolytope() diff --git a/src/LazySets.jl b/src/LazySets.jl index 5a5196e948..4b70234433 100644 --- a/src/LazySets.jl +++ b/src/LazySets.jl @@ -85,4 +85,9 @@ include("Approximations/Approximations.jl") # ============ include("plot_recipes.jl") +# =================================================== +# Load external packages on-demand (using 'Requires') +# =================================================== +include("init.jl") + end # module diff --git a/src/VPolytope.jl b/src/VPolytope.jl index 0354f8802b..66850b249e 100644 --- a/src/VPolytope.jl +++ b/src/VPolytope.jl @@ -104,7 +104,8 @@ function vertices_list(P::VPolytope{N})::Vector{Vector{N}} where {N<:Real} end -@require Polyhedra begin +function load_polyhedra_vpolytope() # function to be loaded by Requires +return quote using CDDLib # default backend import Polyhedra:polyhedron, SimpleHRepresentation, SimpleVRepresentation, @@ -223,4 +224,5 @@ function cartesian_product(P1::VPolytope, P2::VPolytope; backend=CDDLib.CDDLibra return VPolytope(Pcp) end -end +end # quote +end # function load_polyhedra_vpolytope() diff --git a/src/init.jl b/src/init.jl new file mode 100644 index 0000000000..7a441fb929 --- /dev/null +++ b/src/init.jl @@ -0,0 +1,8 @@ +function __init__() + @require Polyhedra = "67491407-f73d-577b-9b50-8179a7c68029" load_polyhedra() +end + +function load_polyhedra() + eval(load_polyhedra_hpolytope()) + eval(load_polyhedra_vpolytope()) +end