-
-
Notifications
You must be signed in to change notification settings - Fork 401
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 symbol in object dictionary with deletion of object #2232
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2232 +/- ##
==========================================
- Coverage 91.31% 91.20% -0.11%
==========================================
Files 42 42
Lines 4261 4174 -87
==========================================
- Hits 3891 3807 -84
+ Misses 370 367 -3
Continue to review full report at Codecov.
|
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.
How does this work for collections of variables, especially if you delete them one-by-one? This was the use case cited in #1956.
If you delete each entry of a container separately then you can do |
What's the point of having an automatic unregister that only works in the corner case of scalar variables? What about making it always manual? |
The user could also delete the container as a whole instead of deleting each separate constraint. @constraint(model, con[...], ...)
for ...
delete(model, con[...])
end We can say "use |
Do we currently have specialized delete method for every type of container? So
|
👍 in favor of |
We could have both and |
Why have to ways to do the same thing? We don't want people to go model = Model()
@variable(model, x)
unregister(model, :x)
@variable(model, x) Now how do I access the first Better to have model = Model()
@variable(model, x)
delete!(model, :x)
@variable(model, x) |
Does |
Maybe I do mean just |
Sort of, but |
be29ac2
to
fa36d25
Compare
fa36d25
to
87968e6
Compare
for i in 2:3 | ||
@test JuMP.is_valid(model, con_ref[i]) | ||
con = constraint_object(con_ref[i]) | ||
@test isequal_canonical(jump_function(con), 3x) |
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.
Why is this loop needed? Why are we worried about constraint_object
returning the wrong value?
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.
It's more for is_valid
that the loop is there but I agree that we could remove it
end | ||
|
||
""" | ||
delete(model::JuMP.AbstractModel, name::Symbol) |
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.
I'm a bit worried about confusion from the overloaded meaning of delete
. There's a big difference between delete(m, x)
and delete(m, :x)
that's understated by the 1-character difference. I'd tend to prefer a different name like unregister
for simply deleting the key from the object dictionary (but could be convinced otherwise).
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.
To be sure we talk about the same thing, you mean unregister
so that the user needs to do:
delete(m, x)
unregister(m, :x)
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.
Yes, I'm proposing delete
and then an explicit unregister
.
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.
@odow has a counter argument against unregister
in #2232 (comment)
Currently failing becausehash
does not work onDenseAxisArray
.Closes #1956