pymc-devs / pymc-examples

Examples of PyMC models, including a library of Jupyter notebooks.
https://www.pymc.io/projects/examples/en/latest/
MIT License
292 stars 251 forks source link

Error with `examples/case_studies/binning.ipynb` #744

Open wd60622 opened 1 week ago

wd60622 commented 1 week ago

Dim names changed

─────────────────────────────────────────────── Error running examples/case_studies/binning.ipynb ────────────────────────────────────────────────

---------------------------------------------------------------------------
Exception encountered at "In [11]":
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[11], line 5
      3 c1.plot(kind="bar", ax=ax, alpha=0.5)
      4 # Plot posterior predictive
----> 5 ppc.posterior_predictive.plot.scatter(x="counts1_dim_0", y="counts1", color="k", alpha=0.2)
      6 # Formatting
      7 ax.set_xticklabels()

File ~/micromamba/envs/pymc-examples/lib/python3.11/site-packages/xarray/plot/accessor.py:1048, in DatasetPlotAccessor.scatter(self, *args,
**kwargs)
   1046 @functools.wraps(dataset_plot.scatter, assigned=("__doc__",))
   1047 def scatter(self, *args, **kwargs) -> PathCollection | FacetGrid[Dataset]:
-> 1048     return dataset_plot.scatter(self._ds, *args, **kwargs)

File ~/micromamba/envs/pymc-examples/lib/python3.11/site-packages/xarray/plot/dataset_plot.py:918, in scatter(ds, x, y, z, hue, hue_style,
markersize, linewidth, figsize, size, aspect, ax, row, col, col_wrap, xincrease, yincrease, add_legend, add_colorbar, add_labels, add_title,
subplot_kws, xscale, yscale, xticks, yticks, xlim, ylim, cmap, vmin, vmax, norm, extend, levels, *args, **kwargs)
    915 locals_.update(locals_.pop("kwargs", {}))
    916 da = _temp_dataarray(ds, y, locals_)
--> 918 return da.plot.scatter(*locals_.pop("args", ()), **locals_)

File ~/micromamba/envs/pymc-examples/lib/python3.11/site-packages/xarray/plot/accessor.py:300, in DataArrayPlotAccessor.scatter(self, *args,
**kwargs)
    298 @functools.wraps(dataarray_plot.scatter, assigned=("__doc__",))
    299 def scatter(self, *args, **kwargs) -> PathCollection | FacetGrid[DataArray]:
--> 300     return dataarray_plot.scatter(self._da, *args, **kwargs)

File ~/micromamba/envs/pymc-examples/lib/python3.11/site-packages/xarray/plot/dataarray_plot.py:957, in _plot1d.<locals>.newplotfunc(***failed
resolving arguments***)
    952 coords_to_plot: MutableMapping = dict(
    953     x=x, z=z, hue=hue, size=size_
    954 )
    955 if not _is_facetgrid:
    956     # Guess what coords to use if some of the values in coords_to_plot are None:
--> 957     coords_to_plot = _guess_coords_to_plot(darray, coords_to_plot, kwargs)
    958 plts = _prepare_plot1d_data(darray, coords_to_plot, plotfunc.__name__)
    959 xplt = plts.pop("x", None)

File ~/micromamba/envs/pymc-examples/lib/python3.11/site-packages/xarray/plot/utils.py:1836, in _guess_coords_to_plot(darray, coords_to_plot,
kwargs, default_guess, ignore_guess_kwargs)
   1833         coords_to_plot = dim
   1835 for k, dim in coords_to_plot.items():
-> 1836     _assert_valid_xy(darray, dim, k)
   1838 return coords_to_plot

File ~/micromamba/envs/pymc-examples/lib/python3.11/site-packages/xarray/plot/utils.py:442, in _assert_valid_xy(darray, xy, name)
    440 if (xy is not None) and (xy not in valid_xy):
    441     valid_xy_str = "', '".join(sorted(tuple(str(v) for v in valid_xy)))
--> 442     raise ValueError(
    443         f"{name} must be one of None, '{valid_xy_str}'. Received '{xy}' instead."
    444     )

ValueError: x must be one of None, 'chain', 'counts1_dim_2', 'draw'. Received 'counts1_dim_0' instead.
OriolAbril commented 6 days ago

I think this will be fixed with the next ArviZ release as it will include https://github.com/arviz-devs/arviz/pull/2395