Skip to content

Commit

Permalink
added deprecation.jl + deprecated generated_quantities in favour of…
Browse files Browse the repository at this point in the history
… `returned_quantities`
  • Loading branch information
torfjelde committed Oct 31, 2024
1 parent 720053a commit fe0403f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/DynamicPPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ include("values_as_in_model.jl")
include("debug_utils.jl")
using .DebugUtils

include("deprecated.jl")

if !isdefined(Base, :get_extension)
using Requires
end
Expand Down
1 change: 1 addition & 0 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@deprecate generated_quantities returned_quantities
16 changes: 8 additions & 8 deletions src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1206,9 +1206,9 @@ function Distributions.loglikelihood(model::Model, chain::AbstractMCMC.AbstractC
end

"""
generated_quantities(model::Model, parameters::NamedTuple)
generated_quantities(model::Model, values, keys)
generated_quantities(model::Model, values, keys)
returned_quantities(model::Model, parameters::NamedTuple)
returned_quantities(model::Model, values, keys)
returned_quantities(model::Model, values, keys)
Execute `model` with variables `keys` set to `values` and return the values returned by the `model`.
Expand All @@ -1233,18 +1233,18 @@ julia> model = demo(randn(10));
julia> parameters = (; s = 1.0, m_shifted=10.0);
julia> generated_quantities(model, parameters)
julia> returned_quantities(model, parameters)
(0.0,)
julia> generated_quantities(model, values(parameters), keys(parameters))
julia> returned_quantities(model, values(parameters), keys(parameters))
(0.0,)
```
"""
function generated_quantities(model::Model, parameters::NamedTuple)
function returned_quantities(model::Model, parameters::NamedTuple)
fixed_model = fix(model, parameters)
return fixed_model()
end

function generated_quantities(model::Model, values, keys)
return generated_quantities(model, NamedTuple{keys}(values))
function returned_quantities(model::Model, values, keys)
return returned_quantities(model, NamedTuple{keys}(values))
end

0 comments on commit fe0403f

Please sign in to comment.