Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Sep 12, 2023
1 parent cf93ba2 commit aa0d10a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
12 changes: 2 additions & 10 deletions src/nlp_expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,7 @@ function _MA.operate!!(
return +(x, *(args...))
end

function _MA.operate(
::typeof(*),
x::Real,
y::GenericNonlinearExpr{V},
) where {V}
function _MA.operate(::typeof(*), x::Real, y::GenericNonlinearExpr{V}) where {V}
if iszero(x)
return zero(value_type(V))
elseif isone(x)
Expand All @@ -423,11 +419,7 @@ function _MA.operate(
end
end

function _MA.operate(
::typeof(*),
x::GenericNonlinearExpr{V},
y::Real,
) where {V}
function _MA.operate(::typeof(*), x::GenericNonlinearExpr{V}, y::Real) where {V}
if iszero(y)
return zero(value_type(V))
elseif isone(y)
Expand Down
4 changes: 2 additions & 2 deletions test/test_nlp_expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -932,10 +932,10 @@ function test_simplification_of_add_and_mul_with_one_or_zero()
model = Model()
@variable(model, x[1:2, 1:3])
@expression(model, f[a in 1:2], sum(x[a, b]^σ[b] * p[a, b] for b in 1:3))
f2 = [x[1,1]^0.5 + (x[1,3]^0.25 * 3.0), x[2, 2]^0.75 * 5.0]
f2 = [x[1, 1]^0.5 + (x[1, 3]^0.25 * 3.0), x[2, 2]^0.75 * 5.0]
@test isequal_canonical(f, f2)
@expression(model, g[a in 1:2], sum(p[a, b] * x[a, b]^σ[b] for b in 1:3))
g2 = [x[1,1]^0.5 + (3.0 * x[1,3]^0.25), 5.0 * x[2, 2]^0.75]
g2 = [x[1, 1]^0.5 + (3.0 * x[1, 3]^0.25), 5.0 * x[2, 2]^0.75]
@test isequal_canonical(g, g2)
return
end
Expand Down

0 comments on commit aa0d10a

Please sign in to comment.