Improve `Dataset.map` `keep_attrs`
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 8/100
Hướng nghiên cứu
This is an open API design question, not a ready task: the issue asks maintainers to choose between three options for Dataset.map's keep_attrs. Start by reading the linked #11020, #11019 and #10726 threads to see what was already decided. Done means a maintainer-agreed design, so a newcomer should comment on the issue and wait for direction before writing code.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What is your issue?
Follow-up to #11020 / #11019.
Since #10726 (v2025.11.0) Dataset.map has no way to keep attributes set by the mapped function: keep_attrs=True overwrites them with the original attrs, keep_attrs=False drops them. #11020 fixes this regression by leaving the function's attrs alone for keep_attrs=False and merging with drop_conflicts for keep_attrs=True. The discussion there showed that the boolean keep_attrs is the wrong interface for map:
- The function receives xarray objects, so it can handle attrs itself.
keep_attrsmainly gets in the way of that (@dcherian, @max-sixty). - Coordinates can still be modified inside the function, so the coordinate attrs of the results need to be combined somehow. That is what the argument should control instead, e.g. as
combine_attrs(@jsignell, @dcherian). - A boolean
keep_attrsis ambiguous: doesFalsemean "drop the input attrs" or "drop all attrs on the output"? (@keewis, @jsignell; see also #10997) mapis basically a loop over.data_vars, and users who need full control can do that loop themselves, e.g.ds.assign({name: func(var) for name, var in ds.data_vars.items()})orxr.merge(..., combine_attrs=...)(@keewis, @jsignell).- Before deprecating
keep_attrs, users need a way to opt into the new behavior (@keewis, @jsignell).
Options discussed for that:
- Add
combine_attrstomap, accepting the usual strategy names / a callable, and deprecatekeep_attrs. This is the option @keewis and @jsignell leaned towards. - Let
keep_attrsaccept strategy names / a callable, likeapply_ufunc, mappingTrueto"override"andFalseto"drop". This avoids a new argument, but a single value can't then control data variable and coordinate attrs separately. - Remove
keep_attrsfrommapwithout replacement and keep whatever attrs the function returns.
- Ngôn ngữ chính
- Python
- Star
- 4.2k
- Fork
- 1.5k
- Merge trung bình
- 2 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 74
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- 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 pydata/xarray
-
xarray removes axis grid from pcolormeshCó thể đã có người làm @Sealdot đã nhận hôm nay. Đang mởbug needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
`DataTree.map_over_datasets` behavior can be obscure sometimesCó thể đã có người làm @mohansree14 đã nhận 24 ngày trước. Đang mởneeds triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pydata/xarray#11813 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Comparing attrs that contain a dict of NumPy arrays raises ValueError in identical / assert_identicalCó thể đã có người làm @SohamXYZDev đã nhận 29 ngày trước. Đang mởbug needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
pydata/xarray#11777 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
RangeIndex` with datetime64 bounds cannot be printed (`Unknown format code 'g'`)Có thể đã có người làm @d-chambers đã nhận 60 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
pydata/xarray#11598 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DataTree constructor error message says dict even though dict is not acceptedCó thể đã có người làm @aryansk đã nhận 100 ngày trước. Đang mởbug contrib-good-first-issue topic-DataTree topic-error reporting
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
pydata/xarray#11514 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của pydata/xarray
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
abetlen/llama-cpp-python#2424 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug IronPython Python 3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
pyrevitlabs/pyRevit#4184 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
CLAW (Agents & Orchestration)Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
jqueryscript/awesome-claude-code#1009 ·
-
tests
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày