Skip to content

Commit 8f649f8

Browse files
test: make tests robust to reordering of equations/unknowns
1 parent b378c44 commit 8f649f8

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

test/clock.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ sss, = ModelingToolkit._structural_simplify!(deepcopy(tss[1]), (inputs[1], ()))
7272
@test isempty(equations(sss))
7373
d = Clock(dt)
7474
k = ShiftIndex(d)
75-
@test observed(sss) == [yd(k + 1) ~ Sample(dt)(y); r(k + 1) ~ 1.0;
76-
ud(k + 1) ~ kp * (r(k + 1) - yd(k + 1))]
75+
@test issetequal(observed(sss),
76+
[yd(k + 1) ~ Sample(dt)(y); r(k + 1) ~ 1.0;
77+
ud(k + 1) ~ kp * (r(k + 1) - yd(k + 1))])
7778

7879
d = Clock(dt)
7980
# Note that TearingState reorders the equations

test/input_output_handling.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ matrices, ssys = linearize(augmented_sys,
414414
augmented_sys.d
415415
], outs;
416416
op = [augmented_sys.u => 0.0, augmented_sys.input.u[2] => 0.0, augmented_sys.d => 0.0])
417+
matrices = ModelingToolkit.reorder_unknowns(
418+
matrices, unknowns(ssys), [ssys.x[2], ssys.integrator.x[1], ssys.x[1]])
417419
@test matrices.A [A [1; 0]; zeros(1, 2) -0.001]
418420
@test matrices.B == I
419421
@test matrices.C == [C zeros(2)]

test/odesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ let
927927
sys_simp = structural_simplify(sys_con)
928928
true_eqs = [D(sys.x) ~ sys.v
929929
D(sys.v) ~ ctrl.kv * sys.v + ctrl.kx * sys.x]
930-
@test isequal(full_equations(sys_simp), true_eqs)
930+
@test issetequal(full_equations(sys_simp), true_eqs)
931931
end
932932

933933
let

0 commit comments

Comments
 (0)