You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 24, 2024. It is now read-only.
So far we've only really implemented dictionary-like get/setitem syntax, but we should add a variety of other ways to select nodes from a tree too. Here are some suggestions:
classDataTree:
...
def__getitem__(self, key: str) ->DataTree|DataArray:
""" Accepts node/variable names, or file-like paths to nodes/variables (inc. '../var'). (Also needs to accommodate indexing somehow.) """
...
defsubset(self, keys: Sequence[str]) ->DataTree:
""" Return new tree containing only nodes with names matching keys. (Could probably be combined with `__getitem__`. Also unsure what the return type should be.) """
...
@propertydefsubtree(self) ->Iterator[DataTree]:
"""An iterator over all nodes in this tree, including both self and all descendants."""
...
deffilter(self, filterfunc: Callable) ->Iterator[DataTree]:
"""Filters subtree by returning only nodes for which `filterfunc(node)` is True."""
...
Are there other types of access that we're missing here? Filtering by regex match? Getting nodes where at least one part of the path matches ("tag-like" access)? Glob?