-
Notifications
You must be signed in to change notification settings - Fork 20
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 increment!
and decrement!
functions.
#314
Added increment!
and decrement!
functions.
#314
Conversation
Hi @Jay-sanjay, thanks for the PR. Unfortunately, that is not the |
@abelsiqueira sir do check is it the way the |
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.
Hi @Jay-sanjay, thanks. That is the correct usage, but you don't have to define the functions again since they are already present in the NLPModels.jl package.
src/julia_interface.jl
Outdated
""" | ||
increment!(nlp, s) | ||
|
||
Increment counter `s` of problem `nlp`. | ||
""" | ||
@inline function increment!(nlp::AbstractNLPModel, s::Symbol) | ||
increment!(nlp, Val(s)) | ||
end | ||
|
||
for fun in fieldnames(Counters) | ||
@eval increment!(nlp::AbstractNLPModel, ::Val{$(Meta.quot(fun))}) = nlp.counters.$fun += 1 | ||
end | ||
|
||
""" | ||
decrement!(nlp, s) | ||
|
||
Decrement counter `s` of problem `nlp`. | ||
""" | ||
|
||
function decrement!(nlp::AbstractNLPModel, s::Symbol) | ||
setproperty!(nlp.counters, s, getproperty(nlp.counters, s) - 1) | ||
end | ||
|
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.
These shouldn't be necessary since they are already defined in NLPModels.jl. Just remove them.
@@ -43,7 +66,7 @@ function NLPModels.objcons!( | |||
f, | |||
) | |||
end | |||
nlp.counters.neval_obj += 1 | |||
increment!(nlp, :neval_obj) |
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, this is the correct usage.
Codecov ReportAll modified lines are covered by tests ✅
📢 Thoughts on this report? Let us know!. |
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.
Thanks @Jay-sanjay, this looks great.
Fixes #292
updated julia_interface.jl