Skip to content

Commit e7a6245

Browse files
test: update tests to account for removal of CSE hack
1 parent f5d037e commit e7a6245

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

test/structural_transformation/utils.jl

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ end
5050
@mtkbuild sys = ODESystem(
5151
[D(x) ~ z[1] + z[2] + foo(z)[1], y[1] ~ 2t, y[2] ~ 3t, z ~ foo(y)], t)
5252
@test length(equations(sys)) == 1
53-
@test length(observed(sys)) == 7
53+
@test length(observed(sys)) == 6
5454
@test any(eq -> isequal(eq.lhs, y), observed(sys))
5555
@test any(eq -> isequal(eq.lhs, z), observed(sys))
5656
prob = ODEProblem(sys, [x => 1.0], (0.0, 1.0), [foo => _tmp_fn])
@@ -75,7 +75,7 @@ end
7575
end
7676
@mtkbuild sys = ODESystem([D(x) ~ y[1] + y[2], y ~ foo(x)], t)
7777
@test length(equations(sys)) == 1
78-
@test length(observed(sys)) == 3
78+
@test length(observed(sys)) == 2
7979
prob = ODEProblem(sys, [x => 1.0], (0.0, 1.0), [foo => _tmp_fn2])
8080
val[] = 0
8181
@test_nowarn prob.f(prob.u0, prob.p, 0.0)
@@ -88,32 +88,9 @@ end
8888
iscall(eq.rhs) && operation(eq.rhs) in [StructuralTransformations.getindex_wrapper,
8989
StructuralTransformations.change_origin]
9090
end
91-
92-
@testset "CSE hack in equations(sys)" begin
93-
val[] = 0
94-
@variables z(t)[1:2]
95-
@mtkbuild sys = ODESystem(
96-
[D(y) ~ foo(x), D(x) ~ sum(y), zeros(2) ~ foo(prod(z))], t)
97-
@test length(equations(sys)) == 5
98-
@test length(observed(sys)) == 2
99-
prob = ODEProblem(
100-
sys, [y => ones(2), z => 2ones(2), x => 3.0], (0.0, 1.0), [foo => _tmp_fn2])
101-
val[] = 0
102-
@test_nowarn prob.f(prob.u0, prob.p, 0.0)
103-
@test val[] == 2
104-
105-
isys = ModelingToolkit.generate_initializesystem(sys)
106-
@test length(unknowns(isys)) == 5
107-
@test length(equations(isys)) == 2
108-
@test !any(equations(isys)) do eq
109-
iscall(eq.rhs) &&
110-
operation(eq.rhs) in [StructuralTransformations.getindex_wrapper,
111-
StructuralTransformations.change_origin]
112-
end
113-
end
11491
end
11592

116-
@testset "array and cse hacks can be disabled" begin
93+
@testset "array hacks can be disabled" begin
11794
@testset "fully_determined = true" begin
11895
@variables x(t) y(t)[1:2] z(t)[1:2]
11996
@parameters foo(::AbstractVector)[1:2]
@@ -129,7 +106,7 @@ end
129106
end
130107

131108
sys2 = structural_simplify(sys; array_hack = false)
132-
@test length(observed(sys2)) == 5
109+
@test length(observed(sys2)) == 4
133110
@test !any(observed(sys2)) do eq
134111
iscall(eq.rhs) && operation(eq.rhs) == StructuralTransformations.change_origin
135112
end
@@ -150,7 +127,7 @@ end
150127
end
151128

152129
sys2 = structural_simplify(sys; array_hack = false, fully_determined = false)
153-
@test length(observed(sys2)) == 5
130+
@test length(observed(sys2)) == 4
154131
@test !any(observed(sys2)) do eq
155132
iscall(eq.rhs) && operation(eq.rhs) == StructuralTransformations.change_origin
156133
end

0 commit comments

Comments
 (0)