Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsipher committed Oct 22, 2023
1 parent 9378424 commit 995ab26
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/expressions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ function map_expression_to_ast(
push!(ex.args, Expr(:call, :*, c, var_mapper(v)))
end
end
if !iszero(aff.constant) || isempty(ex.args)
if !iszero(aff.constant) || isempty(ex.args[2:end])
push!(ex.args, aff.constant)
end
return ex
Expand All @@ -795,7 +795,7 @@ function map_expression_to_ast(
end
end
aff_ex = map_expression_to_ast(var_mapper, op_mapper, quad.aff)
if aff_ex.args != [:+, 0.0] || isempty(ex.args)
if aff_ex.args != [:+, 0.0] || isempty(ex.args[2:end])
append!(ex.args, aff_ex.args[2:end])
end
return ex
Expand Down
2 changes: 1 addition & 1 deletion test/expressions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ end
# test QuadExpr
@testset "QuadExpr" begin
@test map_expression_to_ast(vmap, quad) == :($x * $x + 3 * $x * $w + 2 * $x)
@test map_expression_to_ast(vmap, quad2) == :(2 * $x * $x)
@test map_expression_to_ast(vmap, quad2) == :(+(2 * $x * $x))
@test map_expression_to_ast(vmap, quad0) == :(+(0))
end
# test GenericNonlinearExpr
Expand Down

0 comments on commit 995ab26

Please sign in to comment.