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

Datatree: API for collapsing subtrees #9349

Open
flamingbear opened this issue Aug 13, 2024 · 0 comments
Open

Datatree: API for collapsing subtrees #9349

flamingbear opened this issue Aug 13, 2024 · 0 comments
Labels
topic-DataTree Related to the implementation of a DataTree class

Comments

@flamingbear
Copy link
Contributor

What is your issue?

Originally posted by @TomNicholas in xarray-contrib/datatree#192

Multiple people have requested methods for collapsing children or subtrees into single nodes.

Following on from our discourse discussion @abkfenris @patrickcgray

Also see #3996 (comment) @rabernat @


How about an API like this?

class DataTree:
    def merge_subtree(self, **merge_options) -> DataTree:
        ...

    def concat_subtree(self, **concat_options) -> DataTree:
        ...

    def combine_subtree(self, combine="by_coords", **combine_options) -> DataTree:
        ...

or maybe even the _subtree suffix is superfluous...

Then the usage might be

dt['/path/to/node'] = dt['/path/to/node'].merge_subtree()

You could chain this with the new .filter() too which would be neat.

@flamingbear flamingbear added the topic-DataTree Related to the implementation of a DataTree class label Aug 13, 2024
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

No branches or pull requests

1 participant