Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map_over_datasets - What is the required output of func? #10053

Open
Illviljan opened this issue Feb 16, 2025 · 0 comments
Open

map_over_datasets - What is the required output of func? #10053

Illviljan opened this issue Feb 16, 2025 · 0 comments
Labels
needs triage Issue that has not been reviewed by xarray team member topic-DataTree Related to the implementation of a DataTree class

Comments

@Illviljan
Copy link
Contributor

What is your issue?

The introductory text and type hints seems to match:

func: Callable[..., Dataset | None | tuple[Dataset | None, ...]],

``func`` needs to return a Dataset, tuple of Dataset objects or None in order
to be able to rebuild the subtrees after mapping, as each result will be
assigned to its respective node of a new tree via `DataTree.from_dict`. Any
returned value that is one of these types will be stacked into a separate
tree before returning all of them.

But the parameter doc is more restrictive:

func : callable
Function to apply to datasets with signature:
`func(*args: Dataset, **kwargs) -> Union[Dataset, tuple[Dataset, ...]]`.
(i.e. func must accept at least one Dataset and return at least one Dataset.)

Some examples showing the different return types would be nice as well. I understand the use case of func: Callable[..., Dataset], but I struggle with the other return types.

@Illviljan Illviljan added needs triage Issue that has not been reviewed by xarray team member topic-DataTree Related to the implementation of a DataTree class labels Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue that has not been reviewed by xarray team member topic-DataTree Related to the implementation of a DataTree class
Projects
None yet
Development

No branches or pull requests

1 participant