-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
julia> using DynamicPPL, Distributions
julia> @model function f()
x ~ Normal()
y ~ Normal()
z = Vector{Float64}(undef, 2)
z .~ Normal()
end
f (generic function with 2 methods)
julia> v = VarInfo(f());
julia> keys(v)
4-element Vector{VarName}:
x
y
z[1]
z[2]
julia> values(v) isa VarInfo
true
julia> collect(pairs(v))
ERROR: MethodError: no method matching length(::VarInfo{@NamedTuple{…}, DynamicPPL.AccumulatorTuple{…}})
The function `length` exists, but no method is defined for this combination of argument types.
keys(v)
makes sense, but I would expect values(v)
to give the corresponding values not just return the VarInfo, and pairs(v)
to give the (key, value) pairs (instead I don't even know what it returns because I can't get it into a vector).
This means that you have to do odd things like this, when it should probably just be Dict(pairs(v))
.
julia> Dict(k => v[k] for k in keys(v))
Dict{VarName, Float64} with 4 entries:
y => -1.03936
x => -0.114171
z[2] => 0.417849
z[1] => -0.997633
Metadata
Metadata
Assignees
Labels
No labels