Skip to content

Commit 5478fb3

Browse files
committed
Fixed bug in rand for Model where it would duplicate the non-leaf
contexts in `model.context`
1 parent 32fd6b9 commit 5478fb3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/model.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,9 @@ function Base.rand(rng::Random.AbstractRNG, ::Type{T}, model::Model) where {T}
10511051
evaluate!!(
10521052
model,
10531053
SimpleVarInfo{Float64}(OrderedDict()),
1054-
SamplingContext(rng, SampleFromPrior(), model.context),
1054+
# NOTE: Use `leafcontext` here so we a) avoid overriding the leaf context of `model`,
1055+
# and b) avoid double-stacking the parent contexts.
1056+
SamplingContext(rng, SampleFromPrior(), leafcontext(model.context)),
10551057
),
10561058
)
10571059
return values_as(x, T)

0 commit comments

Comments
 (0)