Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Child dict refactor (also removes anytree dependency) #76

Merged
merged 51 commits into from
Apr 27, 2022

Conversation

TomNicholas
Copy link
Member

@TomNicholas TomNicholas commented Apr 21, 2022

My noodlings so far trying to reimplement the underlying tree structure.

All together this will:

@alexamici


EDIT: This PR introduces a lot of breaking changes (see the whats-new file)

  1. Changes the return type of .children to a FrozenDict (previously Tuple),

  2. Removes tag-like access (i.e. using dt[('folder', 'var')] as an alternative to dt['folder/var'], because I decided that was not helpful.

  3. Changes the syntax for accessing nodes to be more file-like.

  4. Changes the __init__ signature for DataTree.

  5. 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).

@TomNicholas TomNicholas added enhancement New feature or request dependencies Pull requests that update a dependency file labels Apr 21, 2022
@TomNicholas TomNicholas added this to the 0.1 milestone Apr 27, 2022
@TomNicholas TomNicholas merged commit f492787 into xarray-contrib:main Apr 27, 2022
@TomNicholas TomNicholas mentioned this pull request Jun 2, 2022
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
dependencies Pull requests that update a dependency file enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant