Issue with `.sel` and `PintIndex` when using kwarg `method="nearest"`
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Python
- 星标
- 119
- 派生
- 16
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
xarray-contrib/pint-xarray 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 48/100
xarray-contrib/pint-xarray#362 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 45/100
xarray-contrib/pint-xarray#361 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
xarray-contrib/pint-xarray#271 · 7 条评论 ·
-
难度 5/5 一周以上 新手友好度 20/100
xarray-contrib/pint-xarray#269 · 3 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
xarray-contrib/pint-xarray#268 ·
查看 xarray-contrib/pint-xarray 的全部 Issue
相似的 Issue
-
defect from-review v0.9.2
难度 2/5 1-3 小时 新手友好度 86/100
khuisman/mcp-gee-sweet#926 ·
维护者通常 1 天内回复
-
难度 2/5 1 小时以内 新手友好度 84/100
EtanHey/brainlayer#1164 ·
维护者通常 1 天内回复
-
bug security
难度 1/5 1 小时以内 新手友好度 88/100
yunaremaia/vibeguard#141 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
PrismorSec/prismor#599 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复