Skip to content

Document map_over_datasets callback outputs - #11931

Open
Arham-Begani wants to merge 1 commit into
pydata:mainfrom
Arham-Begani:docs/map-over-datasets-outputs
Open

Arham-Begani wants to merge 1 commit into
pydata:mainfrom
Arham-Begani:docs/map-over-datasets-outputs

Conversation

@Arham-Begani

@Arham-Begani Arham-Begani commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Closes #10053.

The documentation of map_over_datasets did not match what the function accepts. DataTree.map_over_datasets said the function "needs to return a Dataset". xr.map_over_datasets mentioned None in one paragraph but said in its parameter docs that the function "must accept at least one Dataset and return at least one Dataset". The user guide said it must return new Dataset objects. In practice the function can also return None, which keeps the node in the result without local data, or a fixed-length tuple of Datasets and Nones, which produces one tree per position.

This PR updates both docstrings and the user guide to describe those return values, and adds two examples to xr.map_over_datasets:

  • Returning None at the root drops the root dataset but keeps the root path and its /station child (readings.groups == ('/', '/station'), with no data variables at the root).
  • Returning (ds.min(), ds.max()) at every node produces two trees, holding the minimum and maximum /station temperatures (8 and 12).

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: OpenAI Codex helped draft the documentation and examples and ran the documentation test. Claude Code wrote this PR description.

Co-authored-by: OpenAI Codex <noreply@openai.com>
@welcome

welcome Bot commented Nov 23, 2026

Copy link
Copy Markdown

Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient.
If you have questions, some answers may be found in our contributing guidelines.

@github-actions github-actions Bot added topic-documentation topic-DataTree Related to the implementation of a DataTree class labels Nov 23, 2026

This branch has not been deployed

No deployments
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 topic-documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

map_over_datasets - What is the required output of func?

1 participant