Skip to content

Commit fcf519a

Browse files
Merge pull request #3587 from AayushSabharwal/as/sort-err
test: make clock test robust to equation ordering
2 parents 30bf372 + 6c0eb42 commit fcf519a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

test/clock.jl

+14-6
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,22 @@ k = ShiftIndex(d)
7676
[yd(k + 1) ~ Sample(dt)(y); r(k + 1) ~ 1.0;
7777
ud(k + 1) ~ kp * (r(k + 1) - yd(k + 1))])
7878

79+
canonical_eqs = map(eqs) do eq
80+
if iscall(eq.lhs) && operation(eq.lhs) isa Differential
81+
return eq
82+
else
83+
return 0 ~ eq.rhs - eq.lhs
84+
end
85+
end
86+
eqs_idxs = findfirst.(isequal.(canonical_eqs), (equations(ci.ts),))
7987
d = Clock(dt)
8088
# Note that TearingState reorders the equations
81-
@test eqmap[1] == ContinuousClock()
82-
@test eqmap[2] == d
83-
@test eqmap[3] == d
84-
@test eqmap[4] == d
85-
@test eqmap[5] == ContinuousClock()
86-
@test eqmap[6] == ContinuousClock()
89+
@test eqmap[eqs_idxs[1]] == d
90+
@test eqmap[eqs_idxs[2]] == d
91+
@test eqmap[eqs_idxs[3]] == d
92+
@test eqmap[eqs_idxs[4]] == ContinuousClock()
93+
@test eqmap[eqs_idxs[5]] == ContinuousClock()
94+
@test eqmap[eqs_idxs[6]] == ContinuousClock()
8795

8896
@test varmap[yd] == d
8997
@test varmap[ud] == d

0 commit comments

Comments
 (0)