Skip to content

Commit 70a00c5

Browse files
Merge pull request #3735 from ctessum/patch-1
switch parse_costs! and parse_constraints
2 parents 9e0568f + 821b4c4 commit 70a00c5

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/systems/model_parsing.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,9 +654,9 @@ function parse_model!(exprs, comps, ext, eqs, icon, vs, ps, sps, c_evts, d_evts,
654654
elseif mname == Symbol("@defaults")
655655
parse_system_defaults!(exprs, arg, dict)
656656
elseif mname == Symbol("@constraints")
657-
parse_costs!(cons, dict, body)
657+
parse_constraints!(cons, dict, body)
658658
elseif mname == Symbol("@costs")
659-
parse_constraints!(costs, dict, body)
659+
parse_costs!(costs, dict, body)
660660
elseif mname == Symbol("@consolidate")
661661
parse_consolidate!(body, dict)
662662
else
@@ -1160,7 +1160,7 @@ function parse_constraints!(cons, dict, body)
11601160
Base.remove_linenums!(body)
11611161
for arg in body.args
11621162
push!(cons, arg)
1163-
push!(dict[:constraints], readable_code.(cons)...)
1163+
push!(dict[:constraints], readable_code(arg))
11641164
end
11651165
end
11661166

@@ -1169,7 +1169,7 @@ function parse_costs!(costs, dict, body)
11691169
Base.remove_linenums!(body)
11701170
for arg in body.args
11711171
push!(costs, arg)
1172-
push!(dict[:costs], readable_code.(costs)...)
1172+
push!(dict[:costs], readable_code(arg))
11731173
end
11741174
end
11751175

test/model_parsing.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,4 +1042,6 @@ end
10421042
@test isequal(constrs[1], EvalAt(0.3)(ex.x) ~ 3)
10431043
@test isequal(constrs[2], ex.y 4)
10441044
@test ModelingToolkit.get_consolidate(ex)([1, 2], [3, 4]) 8 + log(2)
1045+
@test Example.structure[:constraints] == ["(EvalAt(0.3))(x) ~ 3", "y ≲ 4"]
1046+
@test Example.structure[:costs] == ["x + y", "(EvalAt(1))(y) ^ 2"]
10451047
end

0 commit comments

Comments
 (0)