-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Description
The design of my code in ProbabilisticEchoInversion.jl currently relies on a Turing model being able to take a NamedTuple as an argument, which contains the observed data in one of its fields. E.g. something like this:
using Turing
@model function test(data)
m ~ Normal()
data.x ~ Normal(m, 1.0)
end
data = (x = 1.0;)
sample(test(data), NUTS(), 100)This pattern worked until recently, but starting with Turing v0.41.0, it started throwing the following error:
ERROR: setfield!: immutable struct of type NamedTuple cannot be changed
Stacktrace:
[1] setproperty!(x::@NamedTuple{x::Float64}, f::Symbol, v::Float64)
@ Base ./Base.jl:53
[2] macro expansion
@ ~/.julia/packages/DynamicPPL/ze1aD/src/compiler.jl:573 [inlined]
[3] test1(__model__::DynamicPPL.Model{…}, __varinfo__::DynamicPPL.VarInfo{…}, data::@NamedTuple{…})
@ Main ./REPL[5]:3
[4] _evaluate!!(model::DynamicPPL.Model{…}, varinfo::DynamicPPL.VarInfo{…})
@ DynamicPPL ~/.julia/packages/DynamicPPL/ze1aD/src/model.jl:974
[5] evaluate_threadunsafe!!(model::DynamicPPL.Model{…}, varinfo::DynamicPPL.VarInfo{…})
@ DynamicPPL ~/.julia/packages/DynamicPPL/ze1aD/src/model.jl:940
[6] check_model_and_trace(model::DynamicPPL.Model{…}, varinfo::DynamicPPL.VarInfo{…}; error_on_failure::Bool)
@ DynamicPPL.DebugUtils ~/.julia/packages/DynamicPPL/ze1aD/src/debug_utils.jl:428
[7] check_model(model::DynamicPPL.Model{…}, varinfo::DynamicPPL.VarInfo{…}; error_on_failure::Bool)
@ DynamicPPL.DebugUtils ~/.julia/packages/DynamicPPL/ze1aD/src/debug_utils.jl:451
[8] _check_model(model::DynamicPPL.Model{typeof(test1), (:data,), (), (), Tuple{…}, Tuple{}, DynamicPPL.DefaultContext})
@ Turing.Inference ~/.julia/packages/Turing/ObWSF/src/mcmc/abstractmcmc.jl:5
[9] _check_model(model::DynamicPPL.Model{…}, ::NUTS{…})
@ Turing.Inference ~/.julia/packages/Turing/ObWSF/src/mcmc/abstractmcmc.jl:8
[10] sample(rng::Random.TaskLocalRNG, model::DynamicPPL.Model{…}, sampler::NUTS{…}, N::Int64; check_model::Bool, chain_type::Type, initial_params::InitFromUniform{…}, initial_state::Nothing, progress::Bool, nadapts::Int64, discard_adapt::Bool, discard_initial::Int64, kwargs::@Kwargs{})
@ Turing.Inference ~/.julia/packages/Turing/ObWSF/src/mcmc/hmc.jl:101
[11] sample(rng::Random.TaskLocalRNG, model::DynamicPPL.Model{…}, sampler::NUTS{…}, N::Int64)
@ Turing.Inference ~/.julia/packages/Turing/ObWSF/src/mcmc/hmc.jl:86
[12] sample(model::DynamicPPL.Model{…}, spl::NUTS{…}, N::Int64; kwargs::@Kwargs{})
@ Turing.Inference ~/.julia/packages/Turing/ObWSF/src/mcmc/abstractmcmc.jl:71
[13] sample(model::DynamicPPL.Model{…}, spl::NUTS{…}, N::Int64)
@ Turing.Inference ~/.julia/packages/Turing/ObWSF/src/mcmc/abstractmcmc.jl:68
[14] top-level scope
@ REPL[7]:1
Some type information was truncated. Use `show(err)` to see complete types.
Wondering if this change intentional, or required by some other change, or if it could be considered a bug?
Metadata
Metadata
Assignees
Labels
No labels