swap_dims drops coordinate units
还没有人认领这个 Issue。
评估
调研方向
Reproduce the issue with the provided DataArray example and the swap_dims entry point. Trace how quantified coordinates are handled during the dimension swap, then verify that the replacement dimension retains its units while preserving the existing dequantify/quantify behavior.
由索引模型根据 Issue 内容生成。
描述
Using swap_dims on a DataArray with quantified units drops the units on the new dimension. Dequantifying and then quantifying preserves the units:
import xarray as xr
import pint_xarray
da = xr.DataArray(
[1, 2, 3],
dims=['foo'],
coords={
"foo": ('foo', [1,2,3], {"units": "s"}),
"bar": ('foo', [4,5,6], {"units": "kg"})
},
attrs={"units": 'm'}
).pint.quantify()
[
da.bar.pint.units,
da.swap_dims(foo='bar').bar.pint.units,
da.pint.dequantify().swap_dims(foo='bar').pint.quantify().bar.pint.units
]
Returns:
[<Unit('kilogram')>, None, <Unit('kilogram')>]
xarray 2026.1.0, pint-xarray 0.6.0
- 主要语言
- 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 天 新手友好度 55/100
xarray-contrib/pint-xarray#303 · 3 条评论 ·
-
难度 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
-
bug ready for review
难度 2/5 1-3 小时 新手友好度 86/100
odysseus-dev/odysseus#6641 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
happypawspillaro/happypaws#78 ·
维护者通常 4 天内回复
-
pydanty:is-working
难度 2/5 1-3 小时 新手友好度 82/100
pydantic/pydantic-ai#10020 ·
维护者通常 1 天内回复
-
Bug
难度 2/5 1-3 小时 新手友好度 78/100
ansible-collections/ibm_zos_core#2650 ·
-
hw: pvc tests: vllm vllm
难度 2/5 1-3 小时 新手友好度 68/100
intel/intel-xpu-backend-for-triton#8362 ·
维护者通常 1 天内回复