-
Notifications
You must be signed in to change notification settings - Fork 44
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
API for filtering / subsetting #79
Comments
@OriolAbril would these types of functions be sufficient for ArViz's usecases you think? From arviz-devs/arviz#2015 (comment):
This is what I'm suggesting
I'm imagining enabling that via
Or we could potentially add an optional |
One possible point of (approximate) alignment with Xarray API is this issue: pydata/xarray#3894 for selecting using an iterable of variable names. This seems analogous to selecting nodes using |
I had not seen that issue, thanks @dcherian |
I think that would cover everything, but I'll try to think of examples so that we can also have things to test on. We could also provide functions in datatree/xarray/arviz to act as |
Yes that's the tricky bit, because if you want to return a tree then you might need to retain nodes for which For example: def name_is_lowercase(node)
return node.name == node.name.lower()
root = DataTree("a")
child = DataTree(parent=root, name="B")
grandchild = DataTree(parent=child, name="c")
root.filter(name_is_lowercase) This would return nodes "a" and "c", but it couldn't automatically reconstruct them into a tree without also preserving node "B". If |
I added a method to filter nodes based on some condition in #185 |
I've routinely wanted something that says select these variable names from all nodes. This is way too much typing for that: dailies.map_over_subtree(lambda n: n[["KT", "eps", "chi"]]) Perhaps a |
Finally started using DataTree intensively. I also find I am using How would you feel about an accessor or something of the sort ( dt.map_over_subtree(lambda node: node.sel(dim="label"))
# would become
dt.tree.sel(dim="label")
# and the same for .map, .drop_sel, .mean and others |
Closing in favour of pydata/xarray#9342 |
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: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?
The text was updated successfully, but these errors were encountered: