Skip to content

Commit d477137

Browse files
committed
updated doctests for @submodel to include the depwarn + added
warning regarding deprecation of `@submodel`
1 parent c8d567f commit d477137

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

ext/DynamicPPLMCMCChainsExt.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ returned_quantities(m, chain) # <= results in a `Vector` of returned values
6868
```
6969
## Concrete (and simple)
7070
```julia
71-
julia> using DynamicPPL, Turing
71+
julia> using Turing
7272
7373
julia> @model function demo(xs)
7474
s ~ InverseGamma(2, 3)
@@ -87,7 +87,7 @@ julia> model = demo(randn(10));
8787
8888
julia> chain = sample(model, MH(), 10);
8989
90-
julia> returned_quantities(model, chain)
90+
julia> DynamicPPL.returned_quantities(model, chain)
9191
10×1 Array{Tuple{Float64},2}:
9292
(2.1964758025119338,)
9393
(2.1964758025119338,)

src/model.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,8 @@ If a `NamedTuple` is given, `keys=keys(parameters)` and `values=values(parameter
12181218
```jldoctest
12191219
julia> using DynamicPPL, Distributions
12201220
1221+
julia> using DynamicPPL: returned_quantities
1222+
12211223
julia> @model function demo(xs)
12221224
s ~ InverseGamma(2, 3)
12231225
m_shifted ~ Normal(10, √s)

src/submodel_macro.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
55
Run a Turing `model` nested inside of a Turing model.
66
7+
!!! warning
8+
This is deprecated and will be removed in a future release.
9+
Use [`@returned_quantities(model)`](@ref) instead.
10+
711
# Examples
812
913
```jldoctest submodel; setup=:(using Distributions)
@@ -21,6 +25,9 @@ julia> @model function demo2(x, y)
2125
When we sample from the model `demo2(missing, 0.4)` random variable `x` will be sampled:
2226
```jldoctest submodel
2327
julia> vi = VarInfo(demo2(missing, 0.4));
28+
┌ Warning: `@submodel model` is deprecated, use `@returned_quantities model` instead.
29+
│ caller = ip:0x0
30+
└ @ Core :-1
2431
2532
julia> @varname(x) in keys(vi)
2633
true
@@ -62,6 +69,10 @@ Valid expressions for `prefix=...` are:
6269
The prefix makes it possible to run the same Turing model multiple times while
6370
keeping track of all random variables correctly.
6471
72+
!!! warning
73+
This is deprecated and will be removed in a future release.
74+
Use [`@returned_quantities`](@ref) combined with [`@prefix`](@ref) instead.
75+
6576
# Examples
6677
## Example models
6778
```jldoctest submodelprefix; setup=:(using Distributions)
@@ -81,6 +92,9 @@ When we sample from the model `demo2(missing, missing, 0.4)` random variables `s
8192
`sub2.x` will be sampled:
8293
```jldoctest submodelprefix
8394
julia> vi = VarInfo(demo2(missing, missing, 0.4));
95+
┌ Warning: `@submodel model` is deprecated, use `@returned_quantities model` instead.
96+
│ caller = ip:0x0
97+
└ @ Core :-1
8498
8599
julia> @varname(var"sub1.x") in keys(vi)
86100
true
@@ -124,6 +138,9 @@ julia> # When `prefix` is unspecified, no prefix is used.
124138
submodel_noprefix (generic function with 2 methods)
125139
126140
julia> @varname(x) in keys(VarInfo(submodel_noprefix()))
141+
┌ Warning: `@submodel model` is deprecated, use `@returned_quantities model` instead.
142+
│ caller = ip:0x0
143+
└ @ Core :-1
127144
true
128145
129146
julia> # Explicitely don't use any prefix.

0 commit comments

Comments
 (0)