Issue with `.sel` and `PintIndex` when using kwarg `method="nearest"`
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Start by running the minimal example with Python, xarray, and pint-xarray, then inspect the PintIndex.sel entry point reported in the traceback. The issue is done when q.sel(lat=74 * ureg.degrees, method="nearest") succeeds without the unexpected-keyword error and selects the nearest coordinate.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I have tried using the latest version of pint-xarray==0.5.0 which includes units in the coordinates which is exciting but I believe I have found an issue when using .sel and the kwarg method="nearest", which would be used when selecting data nearest to the coordinate value specified but not exactly on the grid.
My guess is that the kwargs are not being passed correctly. Maintaining this functionality would be incredibly useful and hopefully an easy fix.
See a minimal working example below
import xarray as xr
import pint_xarray
ureg = pint_xarray.unit_registry
ds = xr.tutorial.open_dataset("air_temperature")
q = ds.pint.quantify({"lat": "degrees", "lon": "degrees"})
q_75 = q.sel(lat=75 * ureg.degrees)
q_74 = q.sel(lat=74 * ureg.degrees, method="nearest")
which fails with this error
Traceback (most recent call last):
File "/home/ir-pate3/pyro_testing/mwe_pint_xarray.py", line 10, in <module>
q_74 = q.sel(lat=74 * ureg.degrees, method="nearest")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ir-pate3/.local/lib/python3.11/site-packages/xarray/core/dataset.py", line 3249, in sel
query_results = map_index_queries(
^^^^^^^^^^^^^^^^^^
File "/home/ir-pate3/.local/lib/python3.11/site-packages/xarray/core/indexing.py", line 194, in map_index_queries
results.append(index.sel(labels, **options))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: PintIndex.sel() got an unexpected keyword argument 'method'
Currently using pint-xarray=0.5.0 and xarray=2024.11.0.
See related issue here where this breaks our CI tests.
https://github.com/pyro-kinetics/pyrokinetics/issues/446
- Ngôn ngữ chính
- Python
- Star
- 119
- Fork
- 16
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của xarray-contrib/pint-xarray
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
xarray-contrib/pint-xarray#362 · 1 bình luận ·
-
swap_dims drops coordinate unitsĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
xarray-contrib/pint-xarray#361 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
xarray-contrib/pint-xarray#271 · 7 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
xarray-contrib/pint-xarray#269 · 3 bình luận ·
-
improvements for the `PintIndex`Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
xarray-contrib/pint-xarray#268 ·
Tất cả issue của xarray-contrib/pint-xarray
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
SR_SECURITY_DESCRIPTOR.fromString drops the SACL when no DACL is presentCó thể đã có người làm @paul7436 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
equinor/fmu-sumo-uploader#302 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
modelscope/evalscope#1821 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Sanity on ansible-core devel fails: ignore-2.23.txt references the removed import-3.9 testCó thể đã có người làm @yurnov đã nhận hôm nay. Đang mởneeds_triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
ansible-collections/kubernetes.core#1275 ·
Maintainer thường phản hồi trong vòng 1 ngày