Closed
Description
Describe the issue:
When a dimension is left unnamed, pymc
will auto generate the dimension's name based on the tensor's name and the axis number. The problem is that pymc.sample_posterior_predictive
returns a dimension name that is not aligned with what one gets in the observed_data
group.
Reproduceable code example:
import pymc as pm
with pm.Model():
a = pm.Normal("a")
b = pm.Normal("b", a, observed=[-1, 2, 4])
idata = pm.sample()
idata.extend(pm.sample_prior_predictive())
idata = pm.sample_posterior_predictive(idata, extend_inferencedata=True)
assert idata.observed_data.b.dims == idata.prior_predictive.b.dims[2:] # This works!
assert idata.observed_data.b.dims == idata.posterior_predictive.b.dims[2:] # This fails
Error message:
It's a simple `AssertionError`. The telling thing is that the posterior predictive group gets a wrong imputed name because it doesn't ignore the chain and draw dimensions
>>> print(idata.observed_data.b.dims, idata.prior_predictive.b.dims, idata.posterior_predictive.b.dims)
('b_dim_0',) ('chain', 'draw', 'b_dim_0') ('chain', 'draw', 'b_dim_2')
PyMC version information:
PyMC main
Context for the issue:
No response