Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove warning from operator_warn #3911

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions src/operators.jl
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion test/test_operator.jl
Original file line number Diff line number Diff line change
@@ -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
Loading