Skip to content

Commit 3835d01

Browse files
committed
Remove tilde_assume as well
1 parent 4c8809f commit 3835d01

File tree

6 files changed

+12
-25
lines changed

6 files changed

+12
-25
lines changed

docs/src/api.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,3 @@ There is also the _experimental_ [`DynamicPPL.Experimental.determine_suitable_va
516516
DynamicPPL.Experimental.determine_suitable_varinfo
517517
DynamicPPL.Experimental.is_suitable_varinfo
518518
```
519-
520-
### [Model-Internal Functions](@id model_internal)
521-
522-
```@docs
523-
tilde_assume
524-
```

src/context_implementations.jl

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,36 @@
11
# assume
2-
function tilde_assume(context::AbstractContext, args...)
3-
return tilde_assume(childcontext(context), args...)
2+
function tilde_assume!!(context::AbstractContext, right::Distribution, vn, vi)
3+
return tilde_assume!!(childcontext(context), right, vn, vi)
44
end
5-
function tilde_assume(::DefaultContext, right, vn, vi)
5+
function tilde_assume!!(::DefaultContext, right::Distribution, vn, vi)
66
y = getindex_internal(vi, vn)
77
f = from_maybe_linked_internal_transform(vi, vn, right)
88
x, logjac = with_logabsdet_jacobian(f, y)
99
vi = accumulate_assume!!(vi, x, logjac, vn, right)
1010
return x, vi
1111
end
12-
function tilde_assume(context::PrefixContext, right, vn, vi)
12+
function tilde_assume!!(context::PrefixContext, right::Distribution, vn, vi)
1313
# Note that we can't use something like this here:
1414
# new_vn = prefix(context, vn)
15-
# return tilde_assume(childcontext(context), right, new_vn, vi)
15+
# return tilde_assume!!(childcontext(context), right, new_vn, vi)
1616
# This is because `prefix` applies _all_ prefixes in a given context to a
1717
# variable name. Thus, if we had two levels of nested prefixes e.g.
1818
# `PrefixContext{:a}(PrefixContext{:b}(DefaultContext()))`, then the
1919
# first call would apply the prefix `a.b._`, and the recursive call
2020
# would apply the prefix `b._`, resulting in `b.a.b._`.
2121
# This is why we need a special function, `prefix_and_strip_contexts`.
2222
new_vn, new_context = prefix_and_strip_contexts(context, vn)
23-
return tilde_assume(new_context, right, new_vn, vi)
23+
return tilde_assume!!(new_context, right, new_vn, vi)
2424
end
2525

2626
"""
2727
tilde_assume!!(context, right, vn, vi)
2828
2929
Handle assumed variables, e.g., `x ~ Normal()` (where `x` does occur in the model inputs),
3030
accumulate the log probability, and return the sampled value and updated `vi`.
31-
32-
By default, calls `tilde_assume(context, right, vn, vi)` and accumulates the log
33-
probability of `vi` with the returned value.
3431
"""
35-
function tilde_assume!!(context, right, vn, vi)
36-
return if right isa DynamicPPL.Submodel
37-
_evaluate!!(right, vi, context, vn)
38-
else
39-
tilde_assume(context, right, vn, vi)
40-
end
32+
function tilde_assume!!(context, right::DynamicPPL.Submodel, vn, vi)
33+
return _evaluate!!(right, vi, context, vn)
4134
end
4235

4336
# observe

src/contexts.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ PrefixContexts removed.
185185
186186
NOTE: This does _not_ modify any variables in any `ConditionContext` and
187187
`FixedContext` that may be present in the context stack. This is because this
188-
function is only used in `tilde_assume`, which is lower in the tilde-pipeline
188+
function is only used in `tilde_assume!!`, which is lower in the tilde-pipeline
189189
than `contextual_isassumption` and `contextual_isfixed` (the functions which
190190
actually use the `ConditionContext` and `FixedContext` values). Thus, by this
191191
time, any `ConditionContext`s and `FixedContext`s present have already served

src/contexts/init.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ struct InitContext{R<:Random.AbstractRNG,S<:AbstractInitStrategy} <: AbstractCon
134134
end
135135
NodeTrait(::InitContext) = IsLeaf()
136136

137-
function tilde_assume(
137+
function tilde_assume!!(
138138
ctx::InitContext, dist::Distribution, vn::VarName, vi::AbstractVarInfo
139139
)
140140
in_varinfo = haskey(vi, vn)

src/debug_utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ function record_post_tilde_assume!(context::DebugContext, vn, dist, value, varin
253253
return nothing
254254
end
255255

256-
function DynamicPPL.tilde_assume(context::DebugContext, right, vn, vi)
256+
function DynamicPPL.tilde_assume!!(context::DebugContext, right, vn, vi)
257257
record_pre_tilde_assume!(context, vn, right, vi)
258258
value, vi = DynamicPPL.tilde_assume!!(childcontext(context), right, vn, vi)
259259
record_post_tilde_assume!(context, vn, right, value, vi)

src/transforming.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ how to do the transformation, used by e.g. `SimpleVarInfo`.
1212
struct DynamicTransformationContext{isinverse} <: AbstractContext end
1313
NodeTrait(::DynamicTransformationContext) = IsLeaf()
1414

15-
function tilde_assume(
15+
function tilde_assume!!(
1616
::DynamicTransformationContext{isinverse}, right, vn, vi
1717
) where {isinverse}
1818
r = vi[vn, right]

0 commit comments

Comments
 (0)