Skip to content

Commit fd82871

Browse files
committed
added doctests to determine_suitable_varinfo
1 parent 8496968 commit fd82871

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/experimental.jl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,42 @@ See also: [`DynamicPPL.is_suitable_varinfo`](@ref).
4444
4545
# Keyword Arguments
4646
- `only_ddpl`: If `true`, only consider error reports within DynamicPPL.jl.
47+
48+
# Examples
49+
50+
```jldoctest
51+
julia> using DynamicPPL.Experimental: determine_suitable_varinfo
52+
53+
julia> using JET: JET # needs to be loaded for full functionality
54+
55+
julia> @model function model_with_random_support()
56+
x ~ Bernoulli()
57+
if x
58+
y ~ Normal()
59+
else
60+
z ~ Normal()
61+
end
62+
end
63+
model_with_random_support (generic function with 2 methods)
64+
65+
julia> model = model_with_random_support();
66+
67+
julia> # Typed varinfo cannot handle this random support model properly
68+
# as using a single execution of the model will not see all random variables.
69+
# Hence, this this model requires untyped varinfo.
70+
varinfo = determine_suitable_varinfo(model);
71+
72+
julia> varinfo isa typeof(DynamicPPL.untyped_varinfo(model))
73+
true
74+
75+
julia> # In contrast, a simple model with no random support can be handled by typed varinfo.
76+
@model model_with_static_support() = x ~ Normal()
77+
78+
julia> varinfo = determine_suitable_varinfo(model_with_static_support());
79+
80+
julia> varinfo isa typeof(DynamicPPL.typed_varinfo(model_with_static_support()))
81+
true
82+
```
4783
"""
4884
function determine_suitable_varinfo(
4985
model::DynamicPPL.Model,

0 commit comments

Comments
 (0)