Skip to content

Commit f6115c7

Browse files
committed
renamed _make_evaluate_args_and_kwargs to
`gen_evaluator_call_with_types` + added docs, as requested by my dear @willtebbutt
1 parent cf750e1 commit f6115c7

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

docs/src/api.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ DynamicPPL.DebugUtils.model_warntype
219219
DynamicPPL.DebugUtils.model_typed
220220
```
221221

222+
Interally, the type-checking methods make use of the following method for construction of the call with the argument types:
223+
224+
```@docs
225+
DynamicPPL.DebugUtils.gen_evaluator_call_with_types
226+
```
227+
222228
## Advanced
223229

224230
### Variable names

src/debug_utils.jl

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,27 @@ function has_static_constraints(
679679
return all_the_same(transforms)
680680
end
681681

682-
function _make_evaluate_args_and_kwargs(model, varinfo, context)
682+
"""
683+
gen_evaluator_call_with_types(model[, varinfo, context])
684+
685+
Generate the evaluator call and the types of the arguments.
686+
687+
# Arguments
688+
- `model::Model`: The model whose evaluator is of interest.
689+
- `varinfo::AbstractVarInfo`: The varinfo to use when evaluating the model. Default: `VarInfo(model)`.
690+
- `context::AbstractContext`: The context to use when evaluating the model. Default: [`DefaultContext`](@ref).
691+
692+
# Returns
693+
A 2-tuple with the following elements:
694+
- `ftype::Type`: The function type of the evaluator. This is either `model.f` or `Core.kwcall`, depending on whether
695+
the model has keyword arguments.
696+
- `argtypes::Type{<:Tuple}`: The types of the arguments for the evaluator.
697+
"""
698+
function gen_evaluator_call_with_types(
699+
model::Model,
700+
varinfo::AbstractVarInfo=VarInfo(model),
701+
context::AbstractContext=DefaultContext()
702+
)
683703
args, kwargs = DynamicPPL.make_evaluate_args_and_kwargs(model, varinfo, context)
684704
return if isempty(kwargs)
685705
(model.f, Base.typesof(args...))
@@ -709,7 +729,7 @@ function model_warntype(
709729
context::AbstractContext=DefaultContext();
710730
optimize::Bool=false,
711731
)
712-
ftype, argtypes = _make_evaluate_args_and_kwargs(model, varinfo, context)
732+
ftype, argtypes = gen_evaluator_call_with_types(model, varinfo, context)
713733
return InteractiveUtils.code_warntype(ftype, argtypes; optimize=optimize)
714734
end
715735

@@ -734,7 +754,7 @@ function model_typed(
734754
context::AbstractContext=DefaultContext();
735755
optimize::Bool=true,
736756
)
737-
ftype, argtypes = _make_evaluate_args_and_kwargs(model, varinfo, context)
757+
ftype, argtypes = gen_evaluator_call_with_types(model, varinfo, context)
738758
return only(InteractiveUtils.code_typed(ftype, argtypes; optimize=optimize))
739759
end
740760

0 commit comments

Comments
 (0)