DataTree.__contains__ should support pathlike syntax
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
What is your issue?
Summarizing https://github.com/xarray-contrib/datatree/issues/240#issue-1671753316:
Basically DataTree.__getitem__ will currently return more things than DataTree.__contains__ will actually tell you are "in" the tree, which can be confusing.
To fix this __contains__ should support path-like syntax.
I also think that it's convenient that we can separate the "is this key in the local node's variables" question from the "is this path in the tree anywhere" question. In the former case the key will never have a
/character and the latter case it will always have one, so we could perhaps think of this like overloading the__contains__method to behave slightly differently forstrvsPathLiketypes.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the DataTree.contains and DataTree.getitem entry points, then inspect existing DataTree membership tests. Confirm the expected distinction between local-node variable keys and path-like tree membership, and consider the work done when membership behavior is consistent with lookup behavior for the described inputs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100