Fix notebook `intermediate/indexing/why-an-index.ipynb`
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
Research direction
Open intermediate/indexing/why-an-index.ipynb and run it from top to bottom, focusing on Cell In[16] where periodic.sel(angle=q) produces a one-element angle dimension. Check the array-input indexing behavior and update the notebook so the plotted values match q's 721 elements; rerunning the full notebook without the reported dimension error is done.
Written by the indexing model from the issue text.
Description
This notebook (looking at 54df4e2fc01e51905210793f7aa01df0d87be86b ) doesn't run top to bottom
Cell In[16], [line 7](vscode-notebook-cell:?execution_count=16&line=7)
3 periodic_temp = periodic.sel(angle=q)
4
5 fig, ax = plt.subplots(figsize=(9, 4))
6 ax.scatter(sensor_fold, metal_ring.values, color="0.3", s=45, zorder=5, label="the sensors")
----> [7](vscode-notebook-cell:?execution_count=16&line=7) ax.plot(q, periodic_temp, color="tab:green", lw=2.5, label="PeriodicIndex .sel")
8 ax.plot(q, default_temp, color="tab:red", lw=2, label="default index")
9 ax.axvline(0, color="0.6", ls=":", lw=1)
10 ax.set_xlabel("query angle (°)")
File ~/coding/repos/xarray-tutorial/.pixi/envs/default/lib/python3.14/site-packages/matplotlib/axes/_axes.py:1792, in Axes.plot(self, scalex, scaley, data, *args, **kwargs)
1549 """
1550 Plot y versus x as lines and/or markers.
1551
(...) 1789 (``'green'``) or hex strings (``'#008000'``).
1790 """
1791 kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D)
-> [1792](https://file+.vscode-resource.vscode-cdn.net/Users/Hodgs004/coding/repos/xarray-tutorial/intermediate/indexing/~/coding/repos/xarray-tutorial/.pixi/envs/default/lib/python3.14/site-packages/matplotlib/axes/_axes.py:1792) lines = [*self._get_lines(self, *args, data=data, **kwargs)]
1793 for line in lines:
1794 self.add_line(line)
File ~/coding/repos/xarray-tutorial/.pixi/envs/default/lib/python3.14/site-packages/matplotlib/axes/_base.py:331, in _process_plot_var_args.__call__(self, axes, data, return_kwargs, *args, **kwargs)
329 this += args[0],
...
511 if x.ndim > 2 or y.ndim > 2:
512 raise ValueError(f"x and y can be no greater than 2D, but have "
513 f"shapes {x.shape} and {y.shape}")
ValueError: x and y must have same first dimension, but have shapes (721,) and (1,)
I don't think the index is working as expected when angle is an array input.
periodic_temp = periodic.sel(angle=q) # `q.shape` is `(721,)`
# but `periodic_temp.sizes` is `Frozen({'angle': 1})`
cc @ianhi
- Dominant language
- Jupyter Notebook
- Stars
- 204
- Forks
- 121
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from xarray-contrib/xarray-tutorial
-
help wanted
Difficulty 4/5 3-5 days Newbie friendliness 48/100
xarray-contrib/xarray-tutorial#362 · 2 comments · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
-
Difficulty 1/5 Under an hour Newbie friendliness 55/100
xarray-contrib/xarray-tutorial#326 · 1 reaction ·
All issues in xarray-contrib/xarray-tutorial
Similar issues
-
check:passed logos:remove
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
bug needs triage p2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
GoogleCloudPlatform/DataflowTemplates#4273 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
correction metadata
Difficulty 1/5 Under an hour Newbie friendliness 72/100
acl-org/acl-anthology#10025 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100