-
Notifications
You must be signed in to change notification settings - Fork 38
Closed
Description
The bug and the fix:
julia> using Revise, DynamicPPL, Distributions
julia> @model demo() = x ~ Normal()
demo (generic function with 2 methods)
julia> model = demo() | (x = 1.0, )
Model{typeof(demo), (), (), (), Tuple{}, Tuple{}, ConditionContext{(:x,), NamedTuple{(:x,), Tuple{Float64}}, DefaultContext}}(:demo, demo, NamedTuple(), NamedTuple(), ConditionContext((x = 1.0,), DefaultContext()))
julia> varinfo = VarInfo(model)
TypedVarInfo{NamedTuple{(), Tuple{}}, Float64}(NamedTuple(), Base.RefValue{Float64}(-1.4189385332046727), Base.RefValue{Int64}(1))
julia> eltype(varinfo, SampleFromPrior())
Any
julia> # Overload "empty" `TypedVarInfo`.
function Base.eltype(
vi::DynamicPPL.VarInfo{NamedTuple{(),Tuple{}}},
spl::Union{DynamicPPL.AbstractSampler,DynamicPPL.SampleFromPrior}
)
return eltype(DynamicPPL.getlogp(vi))
end
julia> eltype(varinfo, SampleFromPrior())
Float64This can be pretty annoying as it leads to downstream issues such as StackOverflowError when used with MvNormal.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels