Skip to content

Commit 5134ff7

Browse files
committed
renamed returned_quantities to returned as requested
1 parent 0c6bada commit 5134ff7

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

docs/src/api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ It is possible to manually increase (or decrease) the accumulated log density fr
130130
@addlogprob!
131131
```
132132

133-
Return values of the model function for a collection of samples can be obtained with [`returned_quantities`](@ref).
133+
Return values of the model function for a collection of samples can be obtained with [`returned(model, chain)`](@ref).
134134

135135
```@docs
136-
returned_quantities
136+
returned(model, chain)
137137
```
138138

139139
For a chain of samples, one can compute the pointwise log-likelihoods of each observed random variable with [`pointwise_loglikelihoods`](@ref). Similarly, the log-densities of the priors using

ext/DynamicPPLMCMCChainsExt.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function DynamicPPL.varnames(c::MCMCChains.Chains)
4343
end
4444

4545
"""
46-
returned_quantities(model::Model, chain::MCMCChains.Chains)
46+
returned(model::Model, chain::MCMCChains.Chains)
4747
4848
Execute `model` for each of the samples in `chain` and return an array of the values
4949
returned by the `model` for each sample.
@@ -63,7 +63,7 @@ m = demo(data)
6363
chain = sample(m, alg, n)
6464
# To inspect the `interesting_quantity(θ, x)` where `θ` is replaced by samples
6565
# from the posterior/`chain`:
66-
returned_quantities(m, chain) # <= results in a `Vector` of returned values
66+
returned(m, chain) # <= results in a `Vector` of returned values
6767
# from `interesting_quantity(θ, x)`
6868
```
6969
## Concrete (and simple)
@@ -87,7 +87,7 @@ julia> model = demo(randn(10));
8787
8888
julia> chain = sample(model, MH(), 10);
8989
90-
julia> DynamicPPL.returned_quantities(model, chain)
90+
julia> returned(model, chain)
9191
10×1 Array{Tuple{Float64},2}:
9292
(2.1964758025119338,)
9393
(2.1964758025119338,)
@@ -101,7 +101,7 @@ julia> DynamicPPL.returned_quantities(model, chain)
101101
(-0.16489786710222099,)
102102
```
103103
"""
104-
function DynamicPPL.returned_quantities(
104+
function DynamicPPL.returned(
105105
model::DynamicPPL.Model, chain_full::MCMCChains.Chains
106106
)
107107
chain = MCMCChains.get_sections(chain_full, :parameters)

src/DynamicPPL.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export AbstractVarInfo,
122122
fix,
123123
unfix,
124124
prefix,
125-
returned_quantities,
125+
returned,
126126
# Convenience macros
127127
@addlogprob!,
128128
@submodel,
@@ -132,7 +132,8 @@ export AbstractVarInfo,
132132
to_sampleable,
133133
# Deprecated.
134134
@logprob_str,
135-
@prob_str
135+
@prob_str,
136+
generated_quantities
136137

137138
# Reexport
138139
using Distributions: loglikelihood

src/deprecated.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
@deprecate generated_quantities returned_quantities
1+
@deprecate generated_quantities(model, params) returned(model, params)

src/model.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,9 +1206,9 @@ function Distributions.loglikelihood(model::Model, chain::AbstractMCMC.AbstractC
12061206
end
12071207

12081208
"""
1209-
returned_quantities(model::Model, parameters::NamedTuple)
1210-
returned_quantities(model::Model, values, keys)
1211-
returned_quantities(model::Model, values, keys)
1209+
returned(model::Model, parameters::NamedTuple)
1210+
returned(model::Model, values, keys)
1211+
returned(model::Model, values, keys)
12121212
12131213
Execute `model` with variables `keys` set to `values` and return the values returned by the `model`.
12141214
@@ -1218,7 +1218,7 @@ 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
1221+
julia> using DynamicPPL: returned
12221222
12231223
julia> @model function demo(xs)
12241224
s ~ InverseGamma(2, 3)
@@ -1235,18 +1235,18 @@ julia> model = demo(randn(10));
12351235
12361236
julia> parameters = (; s = 1.0, m_shifted=10.0);
12371237
1238-
julia> returned_quantities(model, parameters)
1238+
julia> returned(model, parameters)
12391239
(0.0,)
12401240
1241-
julia> returned_quantities(model, values(parameters), keys(parameters))
1241+
julia> returned(model, values(parameters), keys(parameters))
12421242
(0.0,)
12431243
```
12441244
"""
1245-
function returned_quantities(model::Model, parameters::NamedTuple)
1245+
function returned(model::Model, parameters::NamedTuple)
12461246
fixed_model = fix(model, parameters)
12471247
return fixed_model()
12481248
end
12491249

1250-
function returned_quantities(model::Model, values, keys)
1251-
return returned_quantities(model, NamedTuple{keys}(values))
1250+
function returned(model::Model, values, keys)
1251+
return returned(model, NamedTuple{keys}(values))
12521252
end

src/submodel_macro.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ function prefix_submodel_context(prefix::Bool, ctx)
224224
return ctx
225225
end
226226

227-
const SUBMODEL_DEPWARN_MSG = "`@submodel model` and `@submodel prefix=... model` are deprecated, use `left ~ to_sampleable(model)` and `left ~ to_sampleable(prefix(model, ...))`, respectively, instead."
227+
const SUBMODEL_DEPWARN_MSG = "`@submodel model` and `@submodel prefix=... model` are deprecated, use `left ~ to_sampleable(returned(model))` and `left ~ to_sampleable(returned(prefix(model, ...)))`, respectively, instead."
228228

229229
function submodel(prefix_expr, expr, ctx=esc(:__context__))
230230
prefix_left, prefix = getargs_assignment(prefix_expr)

0 commit comments

Comments
 (0)