-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
This means, for example, it is impossible to fill a typed VarInfo for models like this (instead you have to fill an untyped VarInfo and then only convert it to a typed VarInfo):
julia> using DynamicPPL, Distributions
julia> @model function f()
x = (; a = undef, b = undef)
x.a ~ Normal()
x.b ~ Normal()
end
f (generic function with 2 methods)
julia> DynamicPPL.init!!(f(), DynamicPPL.typed_varinfo(VarInfo()), InitFromPrior())
ERROR: MethodError: Cannot `convert` an object of type
VarName{x,Accessors.PropertyLens{b}} to an object of type
VarName{x,Accessors.PropertyLens{a}}
The function `convert` exists, but no method is defined for this combination of argument types.
Closest candidates are:
convert(::Type{T}, ::T) where T
@ Base Base.jl:126
Stacktrace:
[1] setindex!(h::Dict{VarName{:x, Accessors.PropertyLens{:a}}, Int64}, v0::Int64, key0::VarName{:x, Accessors.PropertyLens{:b}})
@ Base ./dict.jl:346
[2] push!(meta::DynamicPPL.Metadata{Dict{…}, Vector{…}, Vector{…}, Vector{…}}, vn::VarName{:x, Accessors.PropertyLens{…}}, r::Float64, dist::Normal{Float64})
@ DynamicPPL ~/ppl/dppl/src/varinfo.jl:1734
[3] push!!(vi::VarInfo{@NamedTuple{…}, DynamicPPL.AccumulatorTuple{…}}, vn::VarName{:x, Accessors.PropertyLens{…}}, r::Float64, dist::Normal{Float64})
[...]
An even smaller repro:
julia> vi = DynamicPPL.typed_varinfo(VarInfo());
julia> vi = push!!(vi, @varname(x.a), 1.0, Normal());
julia> vi = push!!(vi, @varname(x.b), 2.0, Normal())
ERROR: MethodError:
[...]
Metadata
Metadata
Assignees
Labels
No labels