Open
Description
The code used for generating figure 2.7 no longer works with PYMC5. It fails with ValueError: applied function returned data with an unexpected number of dimensions.
I am not familiar with the ArviZ package and the differences between versions. This being said, the root cause seems to be that the data supplied to the plot_kde
function is incorrectly interpreted. If grabbing and passing the raw numpy array
instead of the xarray DataArray
as in the original code, everything seems to work.
Reference: Code for Figure 2.7
Original code
for idata, ax in zip(idatas, axes):
az.plot_ppc(idata, ax=ax[0], color="C1", alpha=0.01, mean=False, legend=False)
az.plot_kde(idata.observed_data["y"], ax=ax[0], plot_kwargs={"color":"C4", "zorder":3})
...
Proposed change
for idata, ax in zip(idatas, axes):
az.plot_ppc(idata, ax=ax[0], color="C1", alpha=0.01, mean=False, legend=False)
az.plot_kde(idata.observed_data["y"].values, ax=ax[0], plot_kwargs={"color":"C4", "zorder":3})
...
I guess I leave this here primarily as fix for people who stumble across the same issue...
This also applies to Exercise 2E7
Best regards htw