Open
Description
Description
The existing checks assume the same model is used between sample and sample_posterior_predictive, in which case the only variable that can be changed are mutable ones.
However if one wants to sample in a new model (as described in https://www.pymc-labs.io/blog-posts/out-of-model-predictions-with-pymc/), they have to artificially use mutable variables even if they never intend to change them after definition:
import pymc as pm
with pm.Model() as m:
x = pm.ConstantData("x", [0, 0, 0, 0, 0, 0])
b = pm.Normal("b", x)
y = pm.Normal("y", b.sum(), observed=0)
idata = pm.sample()
with pm.Model() as pred_m:
x = pm.ConstantData("x", [0, 0, 0])
# x = pm.MutableData("x", [0, 0, 0]) # This works fine
b = pm.Normal("b", x)
y = pm.Normal("y", b.sum(), observed=0)
idata = pm.sample_posterior_predictive(idata, predictions=True,) # Fails because b isn't resampled
A similar thing happens for variables whose dims
are changed. If they were defined in coords_mutable
it will resample correctly, but not if they were defined as vanilla "constant" coords