Skip to content

Commit

Permalink
Remove warning from operator_warn (#3911)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Jan 13, 2025
1 parent d75a0f8 commit c21bedc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
12 changes: 0 additions & 12 deletions src/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,6 @@ operator_warn(::AbstractModel) = nothing

function operator_warn(model::GenericModel)
model.operator_counter += 1
if model.operator_counter > 20000
@warn(
"The addition operator has been used on JuMP expressions a large " *
"number of times. This warning is safe to ignore but may " *
"indicate that model generation is slower than necessary. For " *
"performance reasons, you should not add expressions in a loop. " *
"Instead of x += y, use add_to_expression!(x,y) to modify x in " *
"place. If y is a single variable, you may also use " *
"add_to_expression!(x, coef, y) for x += coef*y.",
maxlog = 1
)
end
return
end

Expand Down
2 changes: 1 addition & 1 deletion test/test_operator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function test_extension_operator_warn(
# Triggers the increment of operator_counter since lhs has more than
# 50 terms
if i == 20_001 && ModelType <: Model
@test_logs (:warn,) lhs + rhs
@test_nowarn lhs + rhs
else
lhs + rhs
end
Expand Down

0 comments on commit c21bedc

Please sign in to comment.