Skip to content

Commit 0ebb56e

Browse files
committed
Fix doctests
1 parent 0649972 commit 0ebb56e

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/debug_utils.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,17 @@ true
338338
julia> print(trace)
339339
assume: x ~ Normal{Float64}(μ=0.0, σ=1.0) ⟼ -0.670252
340340
341-
julia> issuccess, trace = check_model_and_trace(rng, demo_correct() | (x = 1.0,));
341+
julia> cond_model = model | (x = 1.0,);
342+
343+
julia> issuccess, trace = check_model_and_trace(cond_model, VarInfo(cond_model));
342344
┌ Warning: The model does not contain any parameters.
343345
└ @ DynamicPPL.DebugUtils DynamicPPL.jl/src/debug_utils.jl:342
344346
345347
julia> issuccess
346348
true
347349
348350
julia> print(trace)
349-
observe: 1.0 ~ Normal{Float64}(μ=0.0, σ=1.0)
351+
observe: x (= 1.0) ~ Normal{Float64}(μ=0.0, σ=1.0)
350352
```
351353
352354
## Incorrect model
@@ -359,7 +361,11 @@ julia> @model function demo_incorrect()
359361
end
360362
demo_incorrect (generic function with 2 methods)
361363
362-
julia> issuccess, trace = check_model_and_trace(rng, demo_incorrect(); error_on_failure=true);
364+
julia> # Notice that VarInfo(model_incorrect) evaluates the model, but doesn't actually
365+
# alert us to the issue of `x` being sampled twice.
366+
model = demo_incorrect(); varinfo = VarInfo(model);
367+
368+
julia> issuccess, trace = check_model_and_trace(model, varinfo; error_on_failure=true);
363369
ERROR: varname x used multiple times in model
364370
```
365371
"""

src/simple_varinfo.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,15 @@ Evaluation in transformed space of course also works:
122122
123123
```jldoctest simplevarinfo-general
124124
julia> vi = DynamicPPL.settrans!!(SimpleVarInfo((x = -1.0,)), true)
125-
Transformed SimpleVarInfo((x = -1.0,), (LogPrior = LogPriorAccumulator(0.0), LogLikelihood = LogLikelihoodAccumulator(0.0), NumProduce = NumProduceAccumulator(0)))
125+
Transformed SimpleVarInfo((x = -1.0,), AccumulatorTuple((LogPrior = LogPriorAccumulator(0.0), LogLikelihood = LogLikelihoodAccumulator(0.0), NumProduce = NumProduceAccumulator(0))))
126126
127127
julia> # (✓) Positive probability mass on negative numbers!
128128
getlogjoint(last(DynamicPPL.evaluate!!(m, vi)))
129129
-1.3678794411714423
130130
131131
julia> # While if we forget to indicate that it's transformed:
132132
vi = DynamicPPL.settrans!!(SimpleVarInfo((x = -1.0,)), false)
133-
SimpleVarInfo((x = -1.0,), (LogPrior = LogPriorAccumulator(0.0), LogLikelihood = LogLikelihoodAccumulator(0.0), NumProduce = NumProduceAccumulator(0)))
133+
SimpleVarInfo((x = -1.0,), AccumulatorTuple((LogPrior = LogPriorAccumulator(0.0), LogLikelihood = LogLikelihoodAccumulator(0.0), NumProduce = NumProduceAccumulator(0))))
134134
135135
julia> # (✓) No probability mass on negative numbers!
136136
getlogjoint(last(DynamicPPL.evaluate!!(m, vi)))

0 commit comments

Comments
 (0)