Yes you can do it this way to save the logp into the trace, otherwise you can evaluate it outside of the model by creating/accessing the right function.
Some related discussion see Frequently Asked Questions
So you can do:
with model:
logp_y1_ = pm.Deterministic('logp', y1_.logpt)
then do sample.
Or you can sample first, and then evaluate the logp of y1_
(notice that I also move the conditional outside, so the trace is smaller):
with pm.Model() as model:
l = pm.HalfNormal('l',5.)
cov_func = pm.gp.cov.ExpQuad(1, ls=l)
gp = pm.gp.Marginal(cov_func=cov_func)
y0_ = gp.marginal_likelihood('y0',X0,y0,0.1)
trace = pm.sample(100)
with model:
y1_ = gp.conditional('y1',X1,given={'X':X0,'y':y0,'noise':0.1})
# evaluate logp on one input from the posterior:
point = trace[0] # get a point from trace
point['y1'] = y1
y1_.logp(point)