Skip to content

Commit 0f1f1c6

Browse files
test: separate JET tests into different group
1 parent 2054fc6 commit 0f1f1c6

7 files changed

Lines changed: 131 additions & 24 deletions

File tree

.github/workflows/Tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ jobs:
4646
- ModelingToolkitBase/Extended
4747
- ModelingToolkitBase/RegressionI
4848
- ModelingToolkitBase/Extensions
49+
- ModelingToolkitBase/QA
4950
- SciCompDSL/All
51+
exclude:
52+
- version: "pre"
53+
pkggroup: ModelingToolkitBase/QA
5054
runs-on: ${{ vars.USE_SELF_HOSTED == 'true' && 'self-hosted' || 'ubuntu-latest' }}
5155
steps:
5256
- uses: actions/checkout@v6

lib/ModelingToolkitBase/Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821"
184184
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
185185
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
186186
Ipopt_jll = "9cc047cb-c261-5740-88fc-0cf96f7bdcc7"
187-
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
188187
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
189188
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
190189
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
@@ -212,4 +211,4 @@ Sundials = "c3572dad-4567-51f8-b174-8c6c989267f4"
212211
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
213212

214213
[targets]
215-
test = ["AmplNLWriter", "BenchmarkTools", "BoundaryValueDiffEqMIRK", "BoundaryValueDiffEqAscher", "ControlSystemsBase", "DataInterpolations", "DelayDiffEq", "NonlinearSolve", "ForwardDiff", "Ipopt", "Ipopt_jll", "ModelingToolkitStandardLibrary", "Optimization", "OptimizationIpopt", "OptimizationOptimJL", "OptimizationMOI", "OrdinaryDiffEq", "OrdinaryDiffEqDefault", "REPL", "Random", "ReferenceTests", "SafeTestsets", "StableRNGs", "Statistics", "SteadyStateDiffEq", "Test", "StochasticDiffEq", "Sundials", "StochasticDelayDiffEq", "Pkg", "JET", "OrdinaryDiffEqNonlinearSolve", "Logging", "OptimizationBase", "LinearSolve", "Latexify", "Distributed", "DiffEqNoiseProcess", "DynamicQuantities"]
214+
test = ["AmplNLWriter", "BenchmarkTools", "BoundaryValueDiffEqMIRK", "BoundaryValueDiffEqAscher", "ControlSystemsBase", "DataInterpolations", "DelayDiffEq", "NonlinearSolve", "ForwardDiff", "Ipopt", "Ipopt_jll", "ModelingToolkitStandardLibrary", "Optimization", "OptimizationIpopt", "OptimizationOptimJL", "OptimizationMOI", "OrdinaryDiffEq", "OrdinaryDiffEqDefault", "REPL", "Random", "ReferenceTests", "SafeTestsets", "StableRNGs", "Statistics", "SteadyStateDiffEq", "Test", "StochasticDiffEq", "Sundials", "StochasticDelayDiffEq", "Pkg", "OrdinaryDiffEqNonlinearSolve", "Logging", "OptimizationBase", "LinearSolve", "Latexify", "Distributed", "DiffEqNoiseProcess", "DynamicQuantities"]

lib/ModelingToolkitBase/test/mtkparameters.jl

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ using BlockArrays: BlockedArray, BlockedVector, Block
77
using OrdinaryDiffEq
88
using DiffEqBase
99
using ForwardDiff
10-
using JET
1110
using Test
1211

1312
@discretes c(t)
@@ -187,8 +186,6 @@ ps = [p => 1.0] # Value for `d` is missing
187186
@test_throws "Could not evaluate" ODEProblem(sys, [u0; ps], tspan)
188187
@test_nowarn ODEProblem(sys, [u0; ps; [d => 1.0]], tspan)
189188

190-
# JET tests
191-
192189
# scalar parameters only
193190
function level1()
194191
@parameters p1 = 0.5 [tunable = true] p2 = 1 [tunable = true] p3 = 3 [tunable = false] p4 = 3 [tunable = true] y0
@@ -257,35 +254,16 @@ end
257254
@testset "Type stability of $portion" for portion in [
258255
Tunable(), Discrete(), Constants(),
259256
]
260-
@test_call canonicalize(portion, ps)
261257
@inferred canonicalize(portion, ps)
262258

263-
# broken because the size of a vector of vectors can't be determined at compile time
264-
@test_opt target_modules = (ModelingToolkitBase,) canonicalize(
265-
portion, ps
266-
)
267-
268259
buffer, repack, alias = canonicalize(portion, ps)
269260

270-
# broken because dependent update functions break inference
271-
@test_call target_modules = (ModelingToolkitBase,) SciMLStructures.replace(
272-
portion, ps, ones(length(buffer))
273-
)
274261
@inferred SciMLStructures.replace(
275262
portion, ps, ones(length(buffer))
276263
)
277264
@inferred MTKParameters SciMLStructures.replace(portion, ps, ones(length(buffer)))
278-
@test_opt target_modules = (ModelingToolkitBase,) SciMLStructures.replace(
279-
portion, ps, ones(length(buffer))
280-
)
281265

282-
@test_call target_modules = (ModelingToolkitBase,) SciMLStructures.replace!(
283-
portion, ps, ones(length(buffer))
284-
)
285266
@inferred SciMLStructures.replace!(portion, ps, ones(length(buffer)))
286-
@test_opt target_modules = (ModelingToolkitBase,) SciMLStructures.replace!(
287-
portion, ps, ones(length(buffer))
288-
)
289267
end
290268
end
291269

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[deps]
2+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
3+
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
4+
ModelingToolkitBase = "7771a370-6774-4173-bd38-47e70ca0b839"
5+
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
6+
SciMLStructures = "53ae85a6-f571-4167-b2af-e1d143709226"
7+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
8+
9+
[sources]
10+
ModelingToolkitBase = {path = "../.."}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
using ModelingToolkitBase
2+
using Aqua
3+
4+
Aqua.test_all(ModelingToolkitBase)
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
using ModelingToolkitBase
2+
using ModelingToolkitBase: t_nounits as t, MTKParameters
3+
using SciMLBase
4+
using SciMLStructures: SciMLStructures, canonicalize, Tunable, Discrete, Constants
5+
using JET
6+
using Test
7+
8+
# scalar parameters only
9+
function level1()
10+
@parameters p1 = 0.5 [tunable = true] p2 = 1 [tunable = true] p3 = 3 [tunable = false] p4 = 3 [tunable = true] y0
11+
@variables x(t) = 2 y(t) = y0
12+
D = Differential(t)
13+
14+
eqs = [
15+
D(x) ~ p1 * x - p2 * x * y
16+
D(y) ~ -p3 * y + p4 * x * y
17+
]
18+
19+
sys = mtkcompile(
20+
complete(
21+
System(
22+
eqs, t, name = :sys, bindings = [y0 => 2p4]
23+
)
24+
)
25+
)
26+
return prob = ODEProblem{true, SciMLBase.FullSpecialize}(sys, [], (0.0, 3.0))
27+
end
28+
29+
# scalar and vector parameters
30+
function level2()
31+
@parameters p1 = 0.5 [tunable = true] (p23[1:2] = [1, 3.0]) [tunable = true] p4 = 3 [tunable = false] y0
32+
@variables x(t) = 2 y(t) = y0
33+
D = Differential(t)
34+
35+
eqs = [
36+
D(x) ~ p1 * x - p23[1] * x * y
37+
D(y) ~ -p23[2] * y + p4 * x * y
38+
]
39+
40+
sys = mtkcompile(
41+
complete(
42+
System(
43+
eqs, t, name = :sys, bindings = [y0 => 2p4]
44+
)
45+
)
46+
)
47+
return prob = ODEProblem{true, SciMLBase.FullSpecialize}(sys, [], (0.0, 3.0))
48+
end
49+
50+
# scalar and vector parameters with different scalar types
51+
function level3()
52+
@parameters p1 = 0.5 [tunable = true] (p23[1:2] = [1, 3.0]) [tunable = true] p4::Int = 3 [tunable = true] y0::Int
53+
@variables x(t) = 2 y(t) = y0
54+
D = Differential(t)
55+
56+
eqs = [
57+
D(x) ~ p1 * x - p23[1] * x * y
58+
D(y) ~ -p23[2] * y + p4 * x * y
59+
]
60+
61+
sys = mtkcompile(
62+
complete(
63+
System(
64+
eqs, t, name = :sys, bindings = [y0 => 2p4]
65+
)
66+
)
67+
)
68+
return prob = ODEProblem{true, SciMLBase.FullSpecialize}(sys, [], (0.0, 3.0))
69+
end
70+
71+
@testset "level$i" for (i, prob) in enumerate([level1(), level2(), level3()])
72+
ps = prob.p
73+
@testset "Type stability of $portion" for portion in [
74+
Tunable(), Discrete(), Constants(),
75+
]
76+
@test_call canonicalize(portion, ps)
77+
78+
# broken because the size of a vector of vectors can't be determined at compile time
79+
@test_opt target_modules = (ModelingToolkitBase,) canonicalize(
80+
portion, ps
81+
)
82+
83+
buffer, repack, alias = canonicalize(portion, ps)
84+
85+
# broken because dependent update functions break inference
86+
@test_call target_modules = (ModelingToolkitBase,) SciMLStructures.replace(
87+
portion, ps, ones(length(buffer))
88+
)
89+
@test_opt target_modules = (ModelingToolkitBase,) SciMLStructures.replace(
90+
portion, ps, ones(length(buffer))
91+
)
92+
93+
@test_call target_modules = (ModelingToolkitBase,) SciMLStructures.replace!(
94+
portion, ps, ones(length(buffer))
95+
)
96+
@test_opt target_modules = (ModelingToolkitBase,) SciMLStructures.replace!(
97+
portion, ps, ones(length(buffer))
98+
)
99+
end
100+
end

lib/ModelingToolkitBase/test/runtests.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ function activate_extensions_env()
1010
return Pkg.instantiate()
1111
end
1212

13+
function activate_qa_env()
14+
Pkg.activate("qa")
15+
Pkg.develop([PackageSpec(path = dirname(@__DIR__))])
16+
return Pkg.instantiate()
17+
end
18+
1319
function activate_downstream_env()
1420
Pkg.activate("downstream")
1521
Pkg.develop([PackageSpec(path = dirname(@__DIR__))])
@@ -114,4 +120,10 @@ end
114120
# @safetestset "Auto Differentiation Test" include("extensions/ad.jl")
115121
@safetestset "Dynamic Optimization Collocation Solvers" include("extensions/dynamic_optimization.jl")
116122
end
123+
124+
if GROUP == "All" || GROUP == "QA"
125+
activate_qa_env()
126+
@safetestset "JET Tests" include("qa/jet.jl")
127+
@safetestset "Aqua Tests" include("qa/aqua.jl")
128+
end
117129
end

0 commit comments

Comments
 (0)