pymc-devs / pymc-devs/pymc-examples

Error with `examples/case_studies/binning.ipynb`

Open
#744 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

hackathon
Dominant language
Python
Stars
398
Forks
325
Avg merge
9d 15m
Merged PRs (30d)
1

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open examples/case_studies/binning.ipynb and inspect In [11], especially the posterior_predictive scatter call. Check the available coordinates shown in the error, update the invalid x reference, and rerun the notebook to confirm the plot executes without an exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python
Domain
data-visualization
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.