Skip to content

fix: allow non-mapping chunks in DataTree.chunk#11320

Open
SAY-5 wants to merge 2 commits into
pydata:mainfrom
SAY-5:fix/datatree-chunk-auto-11315
Open

fix: allow non-mapping chunks in DataTree.chunk#11320
SAY-5 wants to merge 2 commits into
pydata:mainfrom
SAY-5:fix/datatree-chunk-auto-11315

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented May 5, 2026

Description

Calling DataTree.chunk("auto") (or with any non-mapping value such as an int) raised TypeError: invalid type for chunks: <class 'str'>. Only mappings are supported, even though the type annotation T_ChunksFreq and the docstring both advertise that strings/ints/"auto" are valid.

This brings DataTree.chunk in line with Dataset.chunk: a non-mapping value is broadcast across all tree dimensions, None emits a FutureWarning instead of raising, and tuples/lists emit the same deprecation warning as Dataset.

Checklist

@github-actions github-actions Bot added the topic-DataTree Related to the implementation of a DataTree class label May 5, 2026
SAY-5 added 2 commits May 24, 2026 21:37
Match Dataset.chunk by accepting strings (e.g. "auto"), ints,
and tuples/lists in DataTree.chunk, broadcasting the value to
all dimensions of the tree. Previously any non-Mapping argument
raised TypeError.

Closes pydata#11315

Signed-off-by: SAY-5 <say.apm35@gmail.com>
Signed-off-by: SAY-5 <say.apm35@gmail.com>
@SAY-5 SAY-5 force-pushed the fix/datatree-chunk-auto-11315 branch from c3a91d5 to 46c5196 Compare May 25, 2026 04:38
@SAY-5
Copy link
Copy Markdown
Author

SAY-5 commented May 25, 2026

Rebased onto current main to resolve the merge conflict. Two kinds of pre-existing CI failures are showing:

  • Mypy: test_backends.py:7776 "Group" has no attribute "create_dataset" - zarr 3.x type annotation gap in the main branch, not related to this PR.
  • properties/test_pandas_roundtrip.py::test_roundtrip_pandas_dataframe_datetime failing on all platforms - hypothesis property test flakiness, unrelated to DataTree.chunk.

Neither failure touches xarray/core/datatree.py or xarray/tests/test_datatree.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic-DataTree Related to the implementation of a DataTree class

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot call .chunk('auto') on DataTree.

1 participant