-
Notifications
You must be signed in to change notification settings - Fork 121
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 global variables #322
Merged
ericphanson
merged 5 commits into
jump-dev:master
from
ericphanson:remove-id-to-variables
Sep 10, 2019
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3b0fc2d
Remove global `id_to_variables`
ericphanson 487c5c9
Use better name for method
ericphanson 09e278c
Remove the other global, `conic_constr_to_constr`
ericphanson 86f5067
Remove `GC.gc()` from `Convex.clearmemory()`
ericphanson 26f73e9
Remove commented line
ericphanson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
function conic_form!(x::Variable, unique_conic_forms::UniqueConicForms=UniqueConicForms()) | ||
if !has_conic_form(unique_conic_forms, x) | ||
add_to_id_to_variables!(unique_conic_forms, x) | ||
if vexity(x) == ConstVexity() | ||
# do exactly what we would for a constant | ||
objective = ConicObj() | ||
objective[objectid(:constant)] = (vec([real(x.value);]),vec([imag(x.value);])) | ||
cache_conic_form!(unique_conic_forms, x, objective) | ||
else | ||
objective = ConicObj() | ||
vec_size = length(x) | ||
|
||
objective[x.id_hash] = (real_conic_form(x), imag_conic_form(x)) | ||
objective[objectid(:constant)] = (spzeros(vec_size, 1), spzeros(vec_size, 1)) | ||
# placeholder values in unique constraints prevent infinite recursion depth | ||
cache_conic_form!(unique_conic_forms, x, objective) | ||
if !(x.sign == NoSign() || x.sign == ComplexSign()) | ||
conic_form!(x.sign, x, unique_conic_forms) | ||
end | ||
for set in x.sets | ||
conic_form!(set, x, unique_conic_forms) | ||
end | ||
end | ||
end | ||
return get_conic_form(unique_conic_forms, x) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Given that
GC.gc()
should never be mandatory in user code as Convex, the function could be removed altogetherThere 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.
Yeah, that's true. I thought it should at least be deprecated though, to give users time to remove it so they aren't hit with errors upon upgrading Convex if they have
Convex.clearmemory()
in their scripts. I wasn't sure about leaving in theGC.gc()
or not; I agree they shouldn't need to be using it, but it was something thatConvex.clearmemory()
was doing, so I thought maybe I should point to it as a replacement in case somehow that's a key part of whatever they are doing.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 changed the wording and removed the
GC.gc()
bit. I don't see any harm in leaving a deprecation message in for a month or two though, to let users comfortably remove the function without getting errors.