Skip to content
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

Shallow copy parent and children in DataTree constructor #9297

Merged
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4b7e367
add tests
TomNicholas Jul 31, 2024
6c56b12
fix by shallow copying
TomNicholas Jul 31, 2024
5db25bd
correct first few tests
TomNicholas Aug 2, 2024
b28cb0c
replace constructors in tests with DataTree.from_dict
TomNicholas Aug 20, 2024
bc543b1
rewrite simple_datatree fixture to use DataTree.from_dict
TomNicholas Aug 20, 2024
a080689
fix incorrect creation of nested tree in formatting test
TomNicholas Aug 20, 2024
b73906e
Merge branch 'main' into datatree_init_dont_modify_inplace
TomNicholas Aug 20, 2024
2a6b88d
Update doctests for from_dict constructor
flamingbear Sep 2, 2024
5ddcb44
swap i and h in doctest example for clarity.
flamingbear Sep 2, 2024
6c496b9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 2, 2024
07d6904
Fix a few mypy errors.
flamingbear Sep 2, 2024
015d2ce
Bonkers way to set type checking
flamingbear Sep 2, 2024
847f238
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 2, 2024
7c530f5
Removes parent keyword from DataTree constructor
flamingbear Sep 3, 2024
9a004d4
fix test_setparent_unnamed_child_node_fails
flamingbear Sep 3, 2024
fe5ae9c
fix test_dont_modify_parent_inplace -> bug?
flamingbear Sep 3, 2024
897b84d
Merge branch 'main' into datatree_init_dont_modify_inplace
TomNicholas Sep 7, 2024
7ce6b56
fix test_create_two_children
TomNicholas Sep 7, 2024
897b589
make .parent read-only, and remove tests which test the parent setter
TomNicholas Sep 7, 2024
9938f3b
update error message to reflect fact that .children is Frozen
TomNicholas Sep 7, 2024
cb7fdfa
fix another test
TomNicholas Sep 7, 2024
1f651cb
add test that parent setter tells you to set children instead
TomNicholas Sep 7, 2024
80b4bcd
fix mypy error due to overriding settable property with read-only pro…
TomNicholas Sep 7, 2024
f4c7243
fix test by not trying to set parent via kwarg
TomNicholas Sep 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update error message to reflect fact that .children is Frozen
TomNicholas committed Sep 7, 2024
commit 9938f3b0c04e288893949000ed2d9aa7f3c5a3dd
2 changes: 1 addition & 1 deletion xarray/core/treenode.py
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ def parent(self) -> Tree | None:
@parent.setter
def parent(self: Tree, new_parent: Tree) -> None:
raise AttributeError(
"Cannot set parent attribute directly, you must modify the children attribute of the other node instead"
"Cannot set parent attribute directly, you must modify the children of the other node instead using dict-like syntax"
)

def _set_parent(