Here is a bare bit of code which produces an error:
import pymc
import numpy as np
a = pymc.Normal('a', 1, 1)
b = np.empty(4, dtype=object)
for i in range(4):
b[i] = 1*a
b[i].__name__ = 'b_%i'%i
M = pymc.MCMC([a,b])
M.sample(10)
M.trace('b_0') # Causes a KeyError:'b_0'
I don't understand why I get a KeyError: 'b_0'
when I try to extract the trace of b_0
and all the other b's. Are the traces just not being saved? If so, is there a way to directly flick some switch to change that without having to make the object using @deterministic.
I looked through it, apparently the trace wasn't being saved. Also, the "flag variable" for keeping the trace isn't .trace
, it's .keep_trace