Skip to content

Commit 0dbf958

Browse files
test: update tests for MTKv9
1 parent baa04ab commit 0dbf958

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

test/downstream/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
1515
[compat]
1616
BoundaryValueDiffEq = "5"
1717
ForwardDiff = "0.10"
18-
ModelingToolkit = "8.37"
18+
ModelingToolkit = "8.37, 9"
1919
NonlinearSolve = "2, 3"
2020
Optimization = "3"
2121
OptimizationOptimJL = "0.1, 0.2"

test/downstream/integrator_indexing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ integrator[lorenz2.x] = 2.0
236236

237237
# integrator2 = integrator(0.1)
238238
# @test integrator2 isa Vector
239-
# @test length(integrator2) == length(states(sys_simplified))
239+
# @test length(integrator2) == length(unknowns(sys_simplified))
240240
# @test first(integrator2) isa Real
241241

242242
# integrator3 = integrator(0.0:1.0:10.0, idxs = [lorenz1.x, lorenz2.x])

test/downstream/remake_autodiff.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ using OrdinaryDiffEq, ModelingToolkit, Zygote, SciMLSensitivity
33
@variables t x(t) o(t)
44
D = Differential(t)
55
function lotka_volterra(; name = name)
6-
states = @variables x(t)=1.0 y(t)=1.0 o(t)
6+
unknowns = @variables x(t)=1.0 y(t)=1.0 o(t)
77
params = @parameters p1=1.5 p2=1.0 p3=3.0 p4=1.0
88
eqs = [
99
D(x) ~ p1 * x - p2 * x * y,
1010
D(y) ~ -p3 * y + p4 * x * y,
1111
o ~ x * y,
1212
]
13-
return ODESystem(eqs, t, states, params; name = name)
13+
return ODESystem(eqs, t, unknowns, params; name = name)
1414
end
1515

1616
@named lotka_volterra_sys = lotka_volterra()

test/downstream/solution_interface.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using ModelingToolkit, OrdinaryDiffEq, RecursiveArrayTools, StochasticDiffEq, Test
2+
# compat for MTKv8 and v9
3+
unknowns = isdefined(ModelingToolkit.states) ? ModelingToolkit.states : ModelingToolkit.unknowns
24

35
### Tests on non-layered model (everything should work). ###
46

@@ -78,5 +80,5 @@ prob = ODEProblem(sys_simplified, u0, tspan, p)
7880
sol = solve(prob, Rodas4())
7981

8082
@test_throws ArgumentError sol[x]
81-
@test in(sol[lorenz1.x], [getindex.(sol.u, 1) for i in 1:length(states(sol.prob.f.sys))])
83+
@test in(sol[lorenz1.x], [getindex.(sol.u, 1) for i in 1:length(unknowns(sol.prob.f.sys))])
8284
@test_throws ArgumentError sol[:x]

test/downstream/symbol_indexing.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using ModelingToolkit, OrdinaryDiffEq, RecursiveArrayTools, SymbolicIndexingInterface, Test
22
using Optimization, OptimizationOptimJL
3+
# compat for MTKv8 and v9
4+
unknowns = isdefined(ModelingToolkit.states) ? ModelingToolkit.states : ModelingToolkit.unknowns
35

46
@parameters t σ ρ β
57
@variables x(t) y(t) z(t)
@@ -122,7 +124,7 @@ sol1 = sol(0.0:1.0:10.0)
122124

123125
sol2 = sol(0.1)
124126
@test sol2 isa Vector
125-
@test length(sol2) == length(states(sys_simplified))
127+
@test length(sol2) == length(unknowns(sys_simplified))
126128
@test first(sol2) isa Real
127129

128130
sol3 = sol(0.0:1.0:10.0, idxs = [lorenz1.x, lorenz2.x])

0 commit comments

Comments
 (0)