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

Fix hygiene in objective macro #1517

Merged
merged 15 commits into from
Oct 5, 2018
Merged

Fix hygiene in objective macro #1517

merged 15 commits into from
Oct 5, 2018

Conversation

blegat
Copy link
Member

@blegat blegat commented Oct 3, 2018

@codecov
Copy link

codecov bot commented Oct 3, 2018

Codecov Report

Merging #1517 into master will increase coverage by 0.02%.
The diff coverage is 92.98%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1517      +/-   ##
==========================================
+ Coverage   89.44%   89.47%   +0.02%     
==========================================
  Files          27       27              
  Lines        3639     3733      +94     
==========================================
+ Hits         3255     3340      +85     
- Misses        384      393       +9
Impacted Files Coverage Δ
src/macros.jl 86.89% <92.98%> (-0.8%) ⬇️
src/variables.jl 93.18% <0%> (-0.28%) ⬇️
src/nlp.jl 90.55% <0%> (+0.34%) ⬆️

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 34c91f9...5f6309f. Read the comment docs.

@mlubin
Copy link
Member

mlubin commented Oct 3, 2018

Needs a test.

Can we make sure all macros work instead of fixing them one by one?

Does this affect 0.18.3?

@blegat
Copy link
Member Author

blegat commented Oct 3, 2018

Can we make sure all macros work instead of fixing them one by one?

Yes, I am working on a better fix that defines two new functions that should be called at the end of every macros. The fix in getloopedcode wasn't sufficient

Does this affect 0.18.3?

Yes, we will need to backport this fix

src/macros.jl Outdated
"""
macro_return(model, code, variable)

Return a code that runs `code` in a local scope which returns the value of `variable`.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Return a block of code that 1. runs the code block code in a local scope and 2. returns the value of a local variable named variable. variable must reference a variable defined by code.

src/macros.jl Outdated

Return runs `code` in a local scope which returns the value of `variable`
and then assign `final_variable` to `escvarname`.
If `registerfun` is given, it registers the value returned by the local scope
Copy link
Member

Choose a reason for hiding this comment

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

registerfun is a function passed in. How do we know that it "registers the value returned by the local scope"?
The docstring should either provide the expected signature or call a concrete function.

src/macros.jl Outdated
$(if registerfun !== nothing
:($registerfun($model, $quotvarname, $variable))
end)
# escvarname should be set in the scope calling the macr
Copy link
Member

Choose a reason for hiding this comment

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

Typo: "macro"

src/macros.jl Outdated
quotvarname, escvarname, final_variable=variable)

Return runs `code` in a local scope which returns the value of `variable`
and then assign `final_variable` to `escvarname`.
Copy link
Member

Choose a reason for hiding this comment

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

Could we take the varname and quotvarname as a single symbol and escape/quote it as needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, I was able to get rid of quotvarname and escvarname. It makes things more readable to isolate this technical details in macro_assign_and_return :)

Copy link
Member

@mlubin mlubin left a comment

Choose a reason for hiding this comment

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

There's a bunch of unrelated .ipynb files included in the PR.

src/macros.jl Outdated
"""
macro_assign_and_return(code, variable, name;
final_variable=variable,
registerfun::Union{Nothing, Function}=nothing,
Copy link
Member

Choose a reason for hiding this comment

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

Style nit: register_fun

@@ -0,0 +1,222 @@
{
Copy link
Member

Choose a reason for hiding this comment

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

Hmm?

@blegat blegat merged commit 0025cf4 into master Oct 5, 2018
@carlocab
Copy link

carlocab commented Oct 6, 2018

Hi there, I'm the one who reported the issue at the discourse page. I can see that this PR has been merged into master, but I'm getting the exact same problems as reported on discourse when I use the master branch. I didn't have those problems in the original PR, however. FYI.

@blegat blegat deleted the bl/objhygiene branch October 16, 2018 06:46
@odow odow mentioned this pull request Mar 13, 2019
34 tasks
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.

None yet

3 participants