Commit 4981dc4
Shallow copy parent and children in DataTree constructor (pydata#9297)
* add tests
* fix by shallow copying
* correct first few tests
* replace constructors in tests with DataTree.from_dict
* rewrite simple_datatree fixture to use DataTree.from_dict
* fix incorrect creation of nested tree in formatting test
* Update doctests for from_dict constructor
* swap i and h in doctest example for clarity.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix a few mypy errors.
* Bonkers way to set type checking
I will happily take something better.
But this was the error I was getting
xarray/tests/test_datatree.py:127: error: Argument 1 to "relative_to" of
"NamedNode" has incompatible type "DataTree[Any] | DataArray"; expected
"NamedNode[Any]" [arg-type]
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Removes parent keyword from DataTree constructor
But it doesn't fix all the tests There's three tests that I don't fully know
what should be tested or if they still make sense.
* fix test_setparent_unnamed_child_node_fails
* fix test_dont_modify_parent_inplace -> bug?
* fix test_create_two_children
* make .parent read-only, and remove tests which test the parent setter
* update error message to reflect fact that .children is Frozen
* fix another test
* add test that parent setter tells you to set children instead
* fix mypy error due to overriding settable property with read-only property
* fix test by not trying to set parent via kwarg
---------
Co-authored-by: Matt Savoie <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>1 parent f438a13 commit 4981dc4
File tree
9 files changed
+216
-161
lines changed- xarray
- core
- tests
9 files changed
+216
-161
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
426 | | - | |
427 | 426 | | |
428 | 427 | | |
429 | 428 | | |
| |||
439 | 438 | | |
440 | 439 | | |
441 | 440 | | |
442 | | - | |
443 | | - | |
444 | 441 | | |
445 | 442 | | |
446 | 443 | | |
| |||
459 | 456 | | |
460 | 457 | | |
461 | 458 | | |
462 | | - | |
463 | | - | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
464 | 462 | | |
465 | 463 | | |
466 | 464 | | |
| |||
497 | 495 | | |
498 | 496 | | |
499 | 497 | | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | 498 | | |
512 | 499 | | |
513 | 500 | | |
| |||
896 | 883 | | |
897 | 884 | | |
898 | 885 | | |
899 | | - | |
| 886 | + | |
900 | 887 | | |
901 | 888 | | |
902 | 889 | | |
| |||
1097 | 1084 | | |
1098 | 1085 | | |
1099 | 1086 | | |
1100 | | - | |
| 1087 | + | |
1101 | 1088 | | |
1102 | 1089 | | |
1103 | 1090 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
59 | 64 | | |
60 | 65 | | |
61 | 66 | | |
| |||
98 | 103 | | |
99 | 104 | | |
100 | 105 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
106 | 116 | | |
107 | 117 | | |
108 | 118 | | |
| |||
208 | 218 | | |
209 | 219 | | |
210 | 220 | | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
215 | 230 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | 231 | | |
223 | 232 | | |
224 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
40 | 34 | | |
41 | 35 | | |
42 | 36 | | |
| |||
46 | 40 | | |
47 | 41 | | |
48 | 42 | | |
49 | | - | |
50 | | - | |
| 43 | + | |
| 44 | + | |
51 | 45 | | |
52 | | - | |
| 46 | + | |
53 | 47 | | |
54 | | - | |
| 48 | + | |
55 | 49 | | |
56 | 50 | | |
57 | 51 | | |
58 | 52 | | |
59 | | - | |
| 53 | + | |
60 | 54 | | |
61 | | - | |
| 55 | + | |
62 | 56 | | |
63 | 57 | | |
64 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
89 | 95 | | |
90 | 96 | | |
91 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
207 | 210 | | |
208 | 211 | | |
209 | 212 | | |
| |||
0 commit comments