Reported by hoehna on 2013-11-11 10:28 UTC
Containers are typically created by assigning to an element. However, this does not create the relevant DeterministicNode holding the container, just a potentially indexed variable holding the element or elements. This causes a number of problems, some of which I exemplify below. The easy solution is to create the DeterministicNode holding the container when the container element and the container are created. Then the DeterministicNode can be named correctly and inconsistencies and name losses exemplified below disappear.
Generally speaking, it would probably be better to use a system of naming that kept the name one place (in the variable slot/variable) and not trying to propagate the names to the DAG nodes themselves. This will require some more substantial changes to the revlanguage code but could be addressed simultaneously with the smart pointers / reference counting issue.
x[1] ~ norm(0,1)
x[2] ~ norm(0,1)
mymodel <- model( x[1] ) # mymodel only includes x[1], not x[2] or x
x
mymodel <- model( x[1] ) # mymodel now includes x[1], x[2] and x, but x is unnamed because
# the DeterministicNode containing x is unnamed (name is empty string)
# Any function call or other reference to x previous to the call to model
# will result in x being included in the model, but without name
mymonitor <- screenmonitor( x ) # Because the name of x is lost, the code was previously printing an arbitrary unnamed model
# variable regardless of whether or not x was included in the model DAG.
# Now an error is generated saying that "x" cannot be found in the model because the monitor
# object does not know what the name of the variable is supposed to be
Reported by hoehna on 2013-11-11 10:28 UTC Containers are typically created by assigning to an element. However, this does not create the relevant DeterministicNode holding the container, just a potentially indexed variable holding the element or elements. This causes a number of problems, some of which I exemplify below. The easy solution is to create the DeterministicNode holding the container when the container element and the container are created. Then the DeterministicNode can be named correctly and inconsistencies and name losses exemplified below disappear.
Generally speaking, it would probably be better to use a system of naming that kept the name one place (in the variable slot/variable) and not trying to propagate the names to the DAG nodes themselves. This will require some more substantial changes to the revlanguage code but could be addressed simultaneously with the smart pointers / reference counting issue.
x[1] ~ norm(0,1) x[2] ~ norm(0,1)
mymodel <- model( x[1] ) # mymodel only includes x[1], not x[2] or x x