Skip to content

Commit 3c204d9

Browse files
committed
add automatic prefixing of submodels + remove support for dot-tilde
since this is ambigious in this case
1 parent 5c289c5 commit 3c204d9

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/context_implementations.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ probability of `vi` with the returned value.
104104
"""
105105
function tilde_assume!!(context, right, vn, vi)
106106
return if is_rhs_model(right)
107-
rand_like!!(right, context, vi)
107+
# Prefix the variables using the `vn`.
108+
rand_like!!(right, prefix(context Symbol(vn)), vi)
108109
else
109110
value, logp, vi = tilde_assume(context, right, vn, vi)
110111
value, acclogp_assume!!(context, vi, logp)
@@ -335,12 +336,13 @@ model inputs), accumulate the log probability, and return the sampled value and
335336
Falls back to `dot_tilde_assume(context, right, left, vn, vi)`.
336337
"""
337338
function dot_tilde_assume!!(context, right, left, vn, vi)
338-
return if is_rhs_model(right)
339-
rand_like!!(right, context, vi)
340-
else
341-
value, logp, vi = dot_tilde_assume(context, right, left, vn, vi)
342-
value, acclogp_assume!!(context, vi, logp)
343-
end
339+
is_rhs_model(right) && throw(
340+
ArgumentError(
341+
"`.~` with a model on the right-hand side is not supported; please use `~`",
342+
),
343+
)
344+
value, logp, vi = dot_tilde_assume(context, right, left, vn, vi)
345+
value, acclogp_assume!!(context, vi, logp)
344346
end
345347

346348
# `dot_assume`

0 commit comments

Comments
 (0)