You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 24, 2024. It is now read-only.
Moves Tree Contents so that simpsons data tree in example is defined. (#301)
* Moves Tree Contents so that simpsons data tree in example is defined.
Also changes :py:meth => :py:class since it's a property not a method.
* Show result of datatree.match operation for clarity.
* fix typo wo => two
---------
Co-authored-by: Tom Nicholas <[email protected]>
Copy file name to clipboardExpand all lines: docs/source/hierarchical-data.rst
+21-20Lines changed: 21 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -369,25 +369,6 @@ You can see this tree is similar to the ``dt`` object above, except that it is m
369
369
370
370
(If you want to keep the name of the root node, you will need to add the ``name`` kwarg to :py:class:`from_dict`, i.e. ``DataTree.from_dict(non_empty_nodes, name=dt.root.name)``.)
371
371
372
-
.. _Tree Contents:
373
-
374
-
Tree Contents
375
-
-------------
376
-
377
-
Hollow Trees
378
-
~~~~~~~~~~~~
379
-
380
-
A concept that can sometimes be useful is that of a "Hollow Tree", which means a tree with data stored only at the leaf nodes.
381
-
This is useful because certain useful tree manipulation operations only make sense for hollow trees.
382
-
383
-
You can check if a tree is a hollow tree by using the :py:meth:`~DataTree.is_hollow` property.
384
-
We can see that the Simpson's family is not hollow because the data variable ``"age"`` is present at some nodes which
385
-
have children (i.e. Abe and Homer).
386
-
387
-
.. ipython:: python
388
-
389
-
simpsons.is_hollow
390
-
391
372
.. _manipulating trees:
392
373
393
374
Manipulating Trees
@@ -412,6 +393,7 @@ We can use :py:meth:`DataTree.match` for this:
412
393
}
413
394
)
414
395
result = dt.match("*/B")
396
+
result
415
397
416
398
We can also subset trees by the contents of the nodes.
417
399
:py:meth:`DataTree.filter` retains only the nodes of a tree that meet a certain condition.
@@ -443,6 +425,25 @@ The result is a new tree, containing only the nodes matching the condition.
443
425
444
426
(Yes, under the hood :py:meth:`~DataTree.filter` is just syntactic sugar for the pattern we showed you in :ref:`iterating over trees` !)
445
427
428
+
.. _Tree Contents:
429
+
430
+
Tree Contents
431
+
-------------
432
+
433
+
Hollow Trees
434
+
~~~~~~~~~~~~
435
+
436
+
A concept that can sometimes be useful is that of a "Hollow Tree", which means a tree with data stored only at the leaf nodes.
437
+
This is useful because certain useful tree manipulation operations only make sense for hollow trees.
438
+
439
+
You can check if a tree is a hollow tree by using the :py:class:`~DataTree.is_hollow` property.
440
+
We can see that the Simpson's family is not hollow because the data variable ``"age"`` is present at some nodes which
441
+
have children (i.e. Abe and Homer).
442
+
443
+
.. ipython:: python
444
+
445
+
simpsons.is_hollow
446
+
446
447
.. _tree computation:
447
448
448
449
Computation
@@ -599,7 +600,7 @@ Notice that corresponding tree nodes do not need to have the same name or contai
599
600
Arithmetic Between Multiple Trees
600
601
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
601
602
602
-
Arithmetic operations like multiplication are binary operations, so as long as we have wo isomorphic trees,
603
+
Arithmetic operations like multiplication are binary operations, so as long as we have two isomorphic trees,
0 commit comments