pydata / pydata/xarray

Datatree: API for collapsing subtrees

Open
#9,349 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic-DataTree
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

What is your issue?

Originally posted by @TomNicholas in https://github.com/xarray-contrib/datatree/issues/192

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

Following on from our discourse discussion @abkfenris @patrickcgray

Also see https://github.com/pydata/xarray/issues/3996#issuecomment-1373993285 @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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the DataTree API proposed in the issue, then read the linked discourse discussion and xarray issue for context. Clarify whether merge_subtree, concat_subtree, combine_subtree, and the _subtree naming are required; done means the API scope and expected behavior are agreed before implementation begins.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.