You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Setupusing DynamicPPL
p1 =PrefixContext{:a}(DefaultContext())
p2 =PrefixContext{:a}(PrefixContext{:b}(DefaultContext()))
p3 =PrefixContext{:a}(SamplingContext(PrefixContext{:b}(DefaultContext())))
p4 =SamplingContext(PrefixContext{:a}(DefaultContext()))
julia>prefix(p1, @varname(x))
a.x
julia>prefix(p2, @varname(x))
b.a.x
julia>prefix(p3, @varname(x))
a.x
julia>prefix(p4, @varname(x))
ERROR: MethodError: no method matching prefix(::SamplingContext{SampleFromPrior, PrefixContext{…}, Random.TaskLocalRNG}, ::VarName{:x, typeof(identity)})
The function`prefix` exists, but no method is defined for this combination of argument types.
Several points:
prefix(p1, @varname(x)) is all good.
It seems to me that it would be more natural for prefix(p2, @varname(x)) to return a.b.x as right now this means that nested submodels have the prefixing occurring in the less intuitive way:
using DynamicPPL, Distributions
@modelfunctionsubsubmodel()
x ~Normal(0,1)
end@modelfunctionsubmodel()
x ~to_submodel(prefix(subsubmodel(), :c), false)
return x
end@modelfunctionparentmodel()
x1 ~to_submodel(prefix(submodel(), :a), false)
x2 ~to_submodel(prefix(submodel(), :b), false)
endkeys(VarInfo(parentmodel()))
# 2-element Vector{VarName{sym, typeof(identity)} where sym}:# c.a.x# c.b.x
The intuitive behaviour for prefix(p3, @varname(x)) would be to prefix with both a and b
Several points:
prefix(p1, @varname(x))
is all good.It seems to me that it would be more natural for
prefix(p2, @varname(x))
to returna.b.x
as right now this means that nested submodels have the prefixing occurring in the less intuitive way:The intuitive behaviour for
prefix(p3, @varname(x))
would be to prefix with botha
andb
prefix(p4, @varname(x))
should traverse the context tree accordingly. This is related to to_submodel does not correctly handle manually specified prefixes when sampling #785, where the underlying problem is that the model is being evaluated with aDebugContext(SamplingContext(PrefixContext...)))
but the varnames aren't prefixed.The text was updated successfully, but these errors were encountered: