Skip to content

Commit d8019e1

Browse files
committed
Fix a couple more cases
1 parent b92280d commit d8019e1

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/test_utils/model_interface.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ Even though it is recommended to implement this by hand for a particular `Model`
9292
a default implementation using [`SimpleVarInfo{<:Dict}`](@ref) is provided.
9393
"""
9494
function varnames(model::Model)
95-
new_model = contextualize(model, SamplingContext(model.context))
96-
return collect(keys(last(DynamicPPL.evaluate!!(new_model, SimpleVarInfo(Dict())))))
95+
return collect(keys(last(DynamicPPL.sample!!(model, SimpleVarInfo(Dict())))))
9796
end
9897

9998
"""

src/varinfo.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ end
186186
"""
187187
untyped_varinfo([rng, ]model[, sampler])
188188
189-
Return a VarInfo object for the given `model` and `context`, which has just a
190-
single `Metadata` as its metadata field.
189+
Construct a VarInfo object for the given `model`, which has just a single
190+
`Metadata` as its metadata field.
191191
192192
# Arguments
193193
- `rng::Random.AbstractRNG`: The random number generator to use during model evaluation
@@ -197,9 +197,7 @@ single `Metadata` as its metadata field.
197197
function untyped_varinfo(
198198
rng::Random.AbstractRNG, model::Model, sampler::AbstractSampler=SampleFromPrior()
199199
)
200-
varinfo = VarInfo(Metadata())
201-
new_model = contextualize(model, SamplingContext(rng, sampler, model.context))
202-
return last(evaluate!!(new_model, varinfo))
200+
return last(sample!!(rng, model, VarInfo(Metadata()), sampler))
203201
end
204202
function untyped_varinfo(model::Model, sampler::AbstractSampler=SampleFromPrior())
205203
return untyped_varinfo(Random.default_rng(), model, sampler)
@@ -311,8 +309,8 @@ end
311309
"""
312310
typed_vector_varinfo([rng, ]model[, sampler])
313311
314-
Return a VarInfo object for the given `model` and `context`, which has a
315-
NamedTuple of `VarNamedVector`s as its metadata field.
312+
Return a VarInfo object for the given `model`, which has a NamedTuple of
313+
`VarNamedVector`s as its metadata field.
316314
317315
# Arguments
318316
- `rng::Random.AbstractRNG`: The random number generator to use during model evaluation

0 commit comments

Comments
 (0)