Skip to content

Commit a4e4bcf

Browse files
authored
Merge pull request #343 from JuliaReach/schillic/extensions
#335 - Use package extensions
2 parents f4219d2 + 7719b3c commit a4e4bcf

File tree

5 files changed

+58
-28
lines changed

5 files changed

+58
-28
lines changed

Project.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,21 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1515
[compat]
1616
Espresso = "0.6"
1717
InteractiveUtils = "<0.0.1, 1.4"
18+
LazySets = "5"
1819
LinearAlgebra = "<0.0.1, 1.4"
1920
MacroTools = "0.5"
2021
MultivariatePolynomials = "0.3, 0.4, 0.5"
2122
RecipesBase = "0.6, 0.7, 0.8, 1.0, 1.1, 1.2"
2223
Requires = "1.3.1"
2324
SparseArrays = "<0.0.1, 1.4"
2425
julia = "1.6"
26+
27+
[extensions]
28+
LazySetsExt = "LazySets"
29+
30+
[extras]
31+
LazySets = "b4f0291d-fe17-52bc-9479-3d1a343d9043"
32+
33+
[weakdeps]
34+
LazySets = "b4f0291d-fe17-52bc-9479-3d1a343d9043"
35+
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

ext/LazySetsExt.jl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module LazySetsExt
2+
3+
import MathematicalSystems
4+
using MathematicalSystems: LinearParametricContinuousSystem,
5+
LinearParametricDiscreteSystem,
6+
LinearControlParametricContinuousSystem,
7+
LinearControlParametricDiscreteSystem
8+
9+
@static if isdefined(Base, :get_extension)
10+
using LazySets: MatrixZonotope
11+
else
12+
using ..LazySets: MatrixZonotope
13+
end
14+
15+
for Z in (:LinearParametricContinuousSystem, :LinearParametricDiscreteSystem)
16+
BaseName = Symbol(replace(string(Z), "Parametric" => ""))
17+
18+
@eval begin
19+
function MathematicalSystems.$(BaseName)(AS::MatrixZonotope)
20+
return $Z(AS)
21+
end
22+
end
23+
end
24+
25+
for Z in (:LinearControlParametricContinuousSystem, :LinearControlParametricDiscreteSystem)
26+
BaseName = Symbol(replace(string(Z), "Parametric" => ""))
27+
28+
@eval begin
29+
function MathematicalSystems.$(BaseName)(AS::MatrixZonotope, BS::MatrixZonotope)
30+
return $Z(AS, BS)
31+
end
32+
end
33+
end
34+
35+
end # module

src/MathematicalSystems.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module MathematicalSystems
22

3-
using Requires
43
using LinearAlgebra, SparseArrays
54
using LinearAlgebra: checksquare
65
import RecipesBase
@@ -221,4 +220,6 @@ include("discretize.jl")
221220

222221
export discretize
223222

223+
include("init.jl")
224+
224225
end # module

src/init.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# optional dependencies
2+
@static if !isdefined(Base, :get_extension)
3+
using Requires
4+
end
5+
6+
@static if !isdefined(Base, :get_extension)
7+
function __init__()
8+
@require LazySets = "b4f0291d-fe17-52bc-9479-3d1a343d9043" include("../ext/LazySetsExt.jl")
9+
end
10+
end

src/systems.jl

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3482,30 +3482,3 @@ for (Z, AZ) in
34823482
end
34833483
end
34843484
end
3485-
3486-
function __init__()
3487-
@require LazySets = "b4f0291d-fe17-52bc-9479-3d1a343d9043" begin
3488-
using .LazySets: MatrixZonotope
3489-
3490-
for Z in (:LinearParametricContinuousSystem, :LinearParametricDiscreteSystem)
3491-
BaseName = Symbol(replace(string(Z), "Parametric" => ""))
3492-
3493-
@eval begin
3494-
function $(BaseName)(AS::MatrixZonotope)
3495-
return $Z(AS)
3496-
end
3497-
end
3498-
end
3499-
3500-
for Z in (:LinearControlParametricContinuousSystem, :LinearControlParametricDiscreteSystem)
3501-
BaseName = Symbol(replace(string(Z), "Parametric" => ""))
3502-
3503-
@eval begin
3504-
function $(BaseName)(AS::MTA,
3505-
BS::MTB) where {MTA<:MatrixZonotope,MTB<:MatrixZonotope}
3506-
return $Z(AS, BS)
3507-
end
3508-
end
3509-
end
3510-
end
3511-
end

0 commit comments

Comments
 (0)