Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Nov 23, 2024
1 parent af46406 commit 6907bd5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/nlp_expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -678,18 +678,19 @@ function _evaluate_expr(
f::Function,
expr::GenericNonlinearExpr,
)
# The result_stack needs to be ::Real because operators like || return a
# ::Bool. Also, some inputs may be ::Int.
stack, result_stack = Any[expr], Real[]
while !isempty(stack)
arg = pop!(stack)
if arg isa GenericNonlinearExpr
# wrap arg in a Tuple to catch when we should evaluate.
push!(stack, (arg,))
for child in reverse(arg.args)
push!(stack, (arg,)) # wrap in (,) to catch when we should eval it.
for child in arg.args
push!(stack, child)
end
elseif arg isa Tuple{<:GenericNonlinearExpr}
f_expr = only(arg)
args = reverse([pop!(result_stack) for _ in 1:length(f_expr.args)])
args = Real[pop!(result_stack) for _ in 1:length(f_expr.args)]
push!(result_stack, _evaluate_expr(registry, f, f_expr, args))
else
push!(result_stack, _evaluate_expr(registry, f, arg))
Expand All @@ -702,7 +703,7 @@ function _evaluate_expr(
registry::MOI.Nonlinear.OperatorRegistry,
::Function,
f_expr::GenericNonlinearExpr,
args::Vector
args::Vector,
)
op, nargs = f_expr.head, length(args)
# TODO(odow): uses private function
Expand Down

0 comments on commit 6907bd5

Please sign in to comment.