Skip to content

Commit 67b378e

Browse files
committed
walk_and_substitute -> substitute
1 parent 2bb61e7 commit 67b378e

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

src/structural_transformation/pantelides.jl

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,6 @@
22
### Reassemble: structural information -> system
33
###
44

5-
# Naive subtree matching, we can make the dict have levels
6-
# Going forward we should look into storing the depth in Terms
7-
function walk_and_substitute(expr, substitution_dict)
8-
if haskey(substitution_dict, expr)
9-
return substitution_dict[expr]
10-
elseif istree(expr)
11-
return similarterm(
12-
expr,
13-
walk_and_substitute(operation(expr), substitution_dict),
14-
map(x->walk_and_substitute(x, substitution_dict), arguments(expr))
15-
)
16-
else
17-
@assert !(expr isa Equation) "RHS cannot contain equations"
18-
return expr
19-
end
20-
end
21-
225
function pantelides_reassemble(sys, eqassoc, assign)
236
s = structure(sys)
247
@unpack fullvars, varassoc = s
@@ -74,7 +57,7 @@ function pantelides_reassemble(sys, eqassoc, assign)
7457
end
7558
rhs = ModelingToolkit.expand_derivatives(D(eq.rhs))
7659
substitution_dict = Dict(x.lhs => x.rhs for x in out_eqs if x !== nothing && x.lhs isa Symbolic)
77-
sub_rhs = walk_and_substitute(rhs, substitution_dict)
60+
sub_rhs = substitute(rhs, substitution_dict)
7861
out_eqs[e] = lhs ~ sub_rhs
7962
end
8063

0 commit comments

Comments
 (0)