-
Notifications
You must be signed in to change notification settings - Fork 94
Add copynames argument to copy #297
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #297 +/- ##
==========================================
+ Coverage 96.18% 96.19% +<.01%
==========================================
Files 25 25
Lines 4192 4227 +35
==========================================
+ Hits 4032 4066 +34
- Misses 160 161 +1
Continue to review full report at Codecov.
|
src/Test/modellike.jl
Outdated
@test MOI.supportsconstraint(dest, MOI.VectorAffineFunction{Float64}, MOI.Zeros) | ||
|
||
copyresult = MOI.copy!(dest, src) | ||
copyresult = MOI.copy!(dest, src; copynames=false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the semicolon isn't needed at call sites, you can say MOI.copy!(dest, src, copynames=false)
src/Utilities/cachingoptimizer.jl
Outdated
function attachoptimizer!(m::CachingOptimizer) | ||
@assert m.state == EmptyOptimizer | ||
copy_result = MOI.copy!(m.optimizer, m.model_cache) | ||
# We do not need to copy names are name-related operation are handled by `m.model_cache` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
malformed sentence. maybe: "we do not need to copy names because name-related operations are handled by m.model_cache
"
attribute_value_map(idxmap, f::MOI.AbstractFunction) = mapvariables(idxmap, f) | ||
attribute_value_map(idxmap, attribute_value) = attribute_value | ||
function defaultcopy!(dest::MOI.ModelLike, src::MOI.ModelLike) | ||
function defaultcopy!(dest::MOI.ModelLike, src::MOI.ModelLike, copynames::Bool) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a deprecation to not immediately break all solver interfaces that use defaultcopy!
src/Utilities/cachingoptimizer.jl
Outdated
@assert m.state == EmptyOptimizer | ||
copy_result = MOI.copy!(m.optimizer, m.model_cache) | ||
# We do not need to copy names because name-related operations are handled by `m.model_cache` | ||
copy_result = MOI.copy!(m.optimizer, m.model_cache; copynames=false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semicolon can be comma here also
src/Utilities/copy.jl
Outdated
attribute_value_map(idxmap, f::MOI.AbstractFunction) = mapvariables(idxmap, f) | ||
attribute_value_map(idxmap, attribute_value) = attribute_value | ||
function defaultcopy!(dest::MOI.ModelLike, src::MOI.ModelLike) | ||
warn("defaultcopy!(dest, src) is deprecated, use defaultcopy!(dest, src, false) instead or defaultcopy!(dest, src, true) if you do not want to copy names.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are false
and true
swapped here? true
is the default, and you use false
if you do not want to copy names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oups, indeed
Closes #291