Fix notebook `intermediate/indexing/why-an-index.ipynb`

Đang mở Phù hợp với người mới
#376 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
75/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
jupyter-notebook, python
Lĩnh vực
data

Hướng nghiên cứu

Mở intermediate/indexing/why-an-index.ipynb và chạy từ đầu đến cuối, tập trung vào Cell In[16], nơi periodic.sel(angle=q) tạo ra một chiều angle có một phần tử. Kiểm tra hành vi lập chỉ mục với đầu vào mảng và cập nhật notebook để các giá trị được vẽ khớp với 721 phần tử của q; hoàn tất việc chạy lại toàn bộ notebook mà không gặp lỗi số chiều đã được báo cáo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Jupyter Notebook
Star
204
Fork
121
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của xarray-contrib/xarray-tutorial

Tất cả issue của xarray-contrib/xarray-tutorial

Issue tương tự

Thêm issue về Data Engineering

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.