I'm working on adding conversion to a DataTree object in the Satpy library and while writing some tests I've come across a quality of life change I'm hoping is possible/allowed to add. Basically, I want to be able to check if a node is in a tree in the same way I can access that node using the /
syntax. For example:
In [1]: from datatree import DataTree In [3]: a = DataTree.from_dict({"a/b/c": None}) In [4]: a["a/b"] Out[4]: DataTree('b', parent="a") └── DataTree('c') In [5]: "a/b" in a Out[5]: False
I expected (with very limited prior usage/knowledge of DataTree) that the __contains__
method would do the same or similar traversal as the __getitem__
method. In the above case the in
line would return True
.
Is there a functional reason why this can't be implemented this way? Any issues or gotchas you can foresee if I were to implement it (performance maybe?)?
Edit: Oops forgot to include the tree creation line.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4