Issue with `.sel` and `PintIndex` when using kwarg `method="nearest"`
まだ誰も着手していません。
評価
調査の方向性
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 ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 1週間以上 初心者へのやさしさ 25/100
xarray-contrib/pint-xarray#271 · コメント 7 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
xarray-contrib/pint-xarray#269 · コメント 3 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
xarray-contrib/pint-xarray#268 ·
xarray-contrib/pint-xarray の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
modelcontextprotocol/python-sdk#3648 ·
メンテナーはふだん 1 日以内に返信
-
docs good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
VenetoStato/giorgio#6 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 70/100
EclipseFdn/open-vsx.org#13831 ·
メンテナーはふだん 1 日以内に返信
-
feature request
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 2 日以内に返信