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

Added Base.empty! method for JuMP.Model. #2198

Merged
merged 2 commits into from
Mar 13, 2020
Merged

Added Base.empty! method for JuMP.Model. #2198

merged 2 commits into from
Mar 13, 2020

Conversation

henriquebecker91
Copy link
Contributor

Not only the method but also its documentation and tests. The documentation is generating and tests passing.

…ts. Documentation is generating and tests passing.
@henriquebecker91
Copy link
Contributor Author

This was discussed with @odow over Discourse (https://discourse.julialang.org/t/empty-for-jump-model-or-jump-direct-model/35673).

Copy link
Member

@odow odow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM assuming tests pass. Thanks for your help.

@codecov
Copy link

codecov bot commented Mar 10, 2020

Codecov Report

Merging #2198 into master will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2198      +/-   ##
==========================================
+ Coverage   91.12%   91.13%   +0.01%     
==========================================
  Files          42       42              
  Lines        4122     4128       +6     
==========================================
+ Hits         3756     3762       +6     
  Misses        366      366              
Impacted Files Coverage Δ
src/JuMP.jl 74.55% <100.00%> (+0.93%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6f9192a...68217c2. Read the comment docs.

src/JuMP.jl Outdated
# inneficiencies).
MOI.empty!(model.moi_backend)
empty!(model.shapes)
empty!(model.bridge_types)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep brodge_types unaltered to be consistent witn MOI.empty! for MOI.Bridges.LazyBridgeOptimizer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Commit message is missing a model.bridge_types after the comma because bash interpreted it as a subshell invocation (sorry) and I did not perceive until after push.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested with just the tests in model.jl, those passed.

@mlubin
Copy link
Member

mlubin commented Mar 12, 2020

For consistency with MOI, I don't think we should extend Base.empty!. Base.empty! is defined as:
"Remove all elements from a collection.". A JuMP model is not a collection (it doesn't implement any sort of collection-like interface), so I don't think this applies. We could define JuMP.empty! instead.

@henriquebecker91
Copy link
Contributor Author

henriquebecker91 commented Mar 12, 2020 via email

@odow
Copy link
Member

odow commented Mar 12, 2020

I agree with @henriquebecker91. Exporting an identical symbol to base Julia is very bad.

We either overload Base.empty!, or we provide JuMP.empty_model!. I vote for Base.empty!, even though it isn't exactly the same semantics.

@mlubin
Copy link
Member

mlubin commented Mar 12, 2020

Ah right, I wasn't thinking about our auto-export. Not much we can do about Julia's weird global namespace. We can go with Base.empty! but I'm not too satisfied with it.

@henriquebecker91
Copy link
Contributor Author

henriquebecker91 commented Mar 13, 2020 via email

@henriquebecker91
Copy link
Contributor Author

I will leave to you two to decide if the name will be changed and, if this is the case, to which name. The current code seems to only need changes if the function name is changed.

@mlubin
Copy link
Member

mlubin commented Mar 13, 2020

The consensus is to not change the name.

@odow odow merged commit 2532e46 into jump-dev:master Mar 13, 2020
@odow
Copy link
Member

odow commented Mar 13, 2020

Thanks for your help @henriquebecker91. I appreciate it.

@henriquebecker91
Copy link
Contributor Author

henriquebecker91 commented Mar 13, 2020 via email

@blegat blegat added this to the 0.21.2 milestone Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants