Skip to content

Commit 352e5fc

Browse files
fixup! fix: make flatten_equations type-stable
1 parent 90f1320 commit 352e5fc

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

src/utils.jl

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,29 +1160,8 @@ without scalarizing occurrences of array variables and return the new list of eq
11601160
function flatten_equations(eqs::Vector{Equation})
11611161
_eqs = Equation[]
11621162
for eq in eqs
1163-
shlhs = SU.shape(eq.lhs)
1164-
if isempty(shlhs)
1165-
push!(_eqs, eq)
1166-
continue
1167-
end
1168-
if length(shlhs) == 1
1169-
lhs = collect(eq.lhs)::Vector{SymbolicT}
1170-
rhs = collect(eq.rhs)::Vector{SymbolicT}
1171-
for (l, r) in zip(lhs, rhs)
1172-
push!(_eqs, l ~ r)
1173-
end
1174-
elseif length(shlhs) == 2
1175-
lhs = collect(eq.lhs)::Matrix{SymbolicT}
1176-
rhs = collect(eq.rhs)::Matrix{SymbolicT}
1177-
for (l, r) in zip(lhs, rhs)
1178-
push!(_eqs, l ~ r)
1179-
end
1180-
else
1181-
lhs = collect(eq.lhs)::Matrix{SymbolicT}
1182-
rhs = collect(eq.rhs)::Matrix{SymbolicT}
1183-
for (l, r) in zip(lhs, rhs)
1184-
push!(_eqs, l ~ r)
1185-
end
1163+
for (i1, i2) in zip(SU.stable_eachindex(eq.lhs), SU.stable_eachindex(eq.rhs))
1164+
push!(_eqs, eq.lhs[i1] ~ eq.rhs[i2])
11861165
end
11871166
end
11881167
return _eqs

0 commit comments

Comments
 (0)