Skip to content

Commit 508033b

Browse files
Add counters field in default counters macro (#470)
* add counter field to default counters macro
1 parent b8454fb commit 508033b

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/nlp/utils.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,7 @@ macro default_counters(Model, inner)
131131
end))
132132
push!(ex.args, :(NLPModels.increment!(nlp::$(esc(Model)), s::Symbol) = increment!(nlp.$inner, s)))
133133
push!(ex.args, :(NLPModels.decrement!(nlp::$(esc(Model)), s::Symbol) = decrement!(nlp.$inner, s)))
134+
135+
push!(ex.args, :(Base.getproperty(nlp::$(esc(Model)), s::Symbol) = ( s == :counters ? nlp.$inner.counters : getfield(nlp ,s))))
134136
ex
135137
end

test/nlp/utils.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ end
2222
nlp = SuperNLPModel{Float64, Vector{Float64}}(SimpleNLPModel())
2323
increment!(nlp, :neval_obj)
2424
@test neval_obj(nlp.model) == 1
25+
@test nlp.counters == nlp.model.counters
2526
end

0 commit comments

Comments
 (0)