This repository has been archived by the owner on Oct 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Child dict refactor (also removes anytree dependency) #76
Merged
TomNicholas
merged 51 commits into
xarray-contrib:main
from
TomNicholas:child_dict_refactor
Apr 27, 2022
Merged
Child dict refactor (also removes anytree dependency) #76
TomNicholas
merged 51 commits into
xarray-contrib:main
from
TomNicholas:child_dict_refactor
Apr 27, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TomNicholas
added
enhancement
New feature or request
dependencies
Pull requests that update a dependency file
labels
Apr 21, 2022
for more information, see https://pre-commit.ci
…datatree into child_dict_refactor
for more information, see https://pre-commit.ci
…datatree into child_dict_refactor
for more information, see https://pre-commit.ci
…datatree into child_dict_refactor
This was referenced Apr 27, 2022
Closed
flamingbear
pushed a commit
to flamingbear/rewritten-datatree
that referenced
this pull request
Jan 19, 2024
…datatree#76 * draft implementation of a TreeNode class which stores children in a dict * separate path-like access out into mixin * pseudocode for node getter * basic idea for a path-like object which inherits from pathlib * pass type checking * implement attach * consolidate tree classes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * passes some basic family tree tests * frozen children * passes all basic family tree tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * copied iterators code over from anytree * get nodes with path-like syntax * relative path method * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * set and get node methods * copy anytree iterators * add anytree license * change iterator import * copy anytree's string renderer * renderer * refactored treenode to use .get * black * updated datatree tests to match new path API * moved io tests to their own file * reimplemented getitem in terms of .get * reimplemented setitem in terms of .update * remove anytree dependency * from_dict constructor * string representation of tree * fixed tree diff * fixed io * removed cheeky print statements * fixed isomorphism checking * fixed map_over_subtree * removed now-uneeded utils.py compatibility functions * fixed tests for mapped dataset api methods * updated API docs * reimplement __setitem__ in terms of _set * fixed bug by ensuring name of child node is changed to match key it is stored under * updated docs * added whats-new, and put all changes from this PR in it * added summary of previous versions * remove outdated ._add_child method Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
My noodlings so far trying to reimplement the underlying tree structure.
All together this will:
Store unnamed child nodes in a dict rather than named children in a tuple, closing Should .children be a dictionary instead of a tuple? #3,
Replace the
TreeNode
class with entirely our own code, so removing the anytree dependencyand closing Remove dependency on anytree #7,
Use a
TreeNode
class which can handle relative paths (e.g. '../var'), closing Re-implement path-like access using pathlib? #12.Make it easier to enable mypy because we won't have missing typing stubs for a key component anymore.
TreeNode
code completely modifiedtest_treenode.py
tests modifiedDataTree.py
code modifiedtest_datatree.py
tests modifiedall other tests modified
anytree
completely removedPasses
pre-commit run --all-files
@alexamici
EDIT: This PR introduces a lot of breaking changes (see the
whats-new
file)Changes the return type of
.children
to a FrozenDict (previously Tuple),Removes tag-like access (i.e. using
dt[('folder', 'var')]
as an alternative todt['folder/var']
, because I decided that was not helpful.Changes the syntax for accessing nodes to be more file-like.
Changes the
__init__
signature forDataTree
.Removes the option to delete all data in a node by assigning
None
to the node (in favour of deleting data using the xarray API), or to create a new empty node in the same way (in favour of assigning an empty DataTree object instead).