Skip to content

Commit 565f077

Browse files
committed
Add changelog entry
1 parent ea60973 commit 565f077

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

HISTORY.md

+19
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@
44

55
**Breaking changes**
66

7+
### Submodels
8+
9+
Variables in a submodel can now be conditioned and fixed in a correct way.
10+
See https://github.com/TuringLang/DynamicPPL.jl/issues/857 for a full illustration, but essentially it means you can now do this:
11+
12+
```julia
13+
@model function inner()
14+
x ~ Normal()
15+
return y ~ Normal()
16+
end
17+
inner_conditioned = inner() | (x=1.0,)
18+
@model function outer()
19+
return a ~ to_submodel(inner_conditioned)
20+
end
21+
```
22+
23+
and the `inner.x` variable will be correctly conditioned.
24+
(Previously, you would have to condition `inner()` with the variable `a.x`, meaning that you would need to know what prefix to use before you had actually prefixed it.)
25+
726
### AD testing utilities
827

928
`DynamicPPL.TestUtils.AD.run_ad` now links the VarInfo by default.

src/contexts.jl

+8
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,14 @@ end
691691
Apply `PrefixContext`s to any conditioned or fixed values inside them, and remove
692692
the `PrefixContext`s from the context stack.
693693
694+
!!! note
695+
If you are reading this docstring, you might probably be interested in a more
696+
thorough explanation of how PrefixContext and ConditionContext / FixedContext
697+
interact with one another, especially in the context of submodels.
698+
The DynamicPPL documentation contains [a separate page on this
699+
topic](https://turinglang.org/DynamicPPL.jl/previews/PR892/internals/submodel_condition/)
700+
which explains this in much more detail.
701+
694702
```jldoctest
695703
julia> using DynamicPPL: collapse_prefix_stack
696704

0 commit comments

Comments
 (0)