@@ -1002,10 +1002,11 @@ def total_branch_length(self):
10021002
10031003 As this is defined by a traversal of the tree, technically we
10041004 return the sum of all branch lengths that are reachable from
1005- roots. Thus, this is the sum of all branches that are ancestral
1005+ roots. Thus, this is the total length of all branches that are connected
10061006 to at least one sample. This distinction is only important
10071007 in tree sequences that contain 'dead branches', i.e., those
1008- that define topology not ancestral to any samples.
1008+ that define topology that is not connected to a tree root
1009+ (see :ref:`sec_data_model_tree_dead_leaves_and_branches`)
10091010
10101011 :return: The sum of lengths of branches in this tree.
10111012 :rtype: float
@@ -1374,6 +1375,16 @@ def is_leaf(self, u):
13741375 Returns True if the specified node is a leaf. A node :math:`u` is a
13751376 leaf if it has zero children.
13761377
1378+ .. note::
1379+ :math:`u` can be any node in the entire tree sequence, including ones
1380+ which are not connected via branches to a root node of the tree (and which
1381+ are therefore not conventionally considered part of the tree). Indeed, if
1382+ there are many trees in the tree sequence, it is common for the majority of
1383+ non-sample nodes to be :meth:`isolated<is_isolated>` in any one
1384+ tree. By the definition above, this method will return ``True`` for such
1385+ a tree when a node of this sort is specified. Such nodes can be thought of
1386+ as "dead leaves", see :ref:`sec_data_model_tree_dead_leaves_and_branches`.
1387+
13771388 :param int u: The node of interest.
13781389 :return: True if u is a leaf node.
13791390 :rtype: bool
@@ -1383,7 +1394,8 @@ def is_leaf(self, u):
13831394 def is_isolated (self , u ):
13841395 """
13851396 Returns True if the specified node is isolated in this tree: that is
1386- it has no parents and no children. Sample nodes that are isolated
1397+ it has no parents and no children (note that all isolated nodes in the tree
1398+ are therefore also :meth:`leaves<Tree.is_leaf>`). Sample nodes that are isolated
13871399 and have no mutations above them are used to represent
13881400 :ref:`missing data<sec_data_model_missing_data>`.
13891401
@@ -2004,9 +2016,17 @@ def get_leaves(self, u):
20042016
20052017 def leaves (self , u = None ):
20062018 """
2007- Returns an iterator over all the leaves in this tree that are
2008- underneath the specified node. If u is not specified, return all leaves
2009- in the tree.
2019+ Returns an iterator over all the leaves in this tree that descend from
2020+ the specified node. If :math:`u` is not specified, return all leaves on
2021+ the tree (i.e. all leaves reachable from the tree root(s), see note below).
2022+
2023+ .. note::
2024+ :math:`u` can be any node in the entire tree sequence, including ones
2025+ which are not connected via branches to a root node of the tree. If
2026+ called on such a node, the iterator will return "dead" leaves
2027+ (see :ref:`sec_data_model_tree_dead_leaves_and_branches`) which cannot
2028+ be reached from a root of this tree. However, dead leaves will never be
2029+ returned if :math:`u` is left unspecified.
20102030
20112031 :param int u: The node of interest.
20122032 :return: An iterator over all leaves in the subtree rooted at u.
@@ -2309,15 +2329,15 @@ def push(nodes):
23092329
23102330 def nodes (self , root = None , order = "preorder" ):
23112331 """
2312- Returns an iterator over the node IDs reachable from the root(s) in this
2332+ Returns an iterator over the node IDs reachable from the specified node in this
23132333 tree in the specified traversal order.
23142334
23152335 .. note::
23162336 Unlike the :meth:`TreeSequence.nodes` method, this iterator produces
23172337 integer node IDs, not :class:`Node` objects.
23182338
23192339 If the ``root`` parameter is not provided or ``None``, iterate over all
2320- nodes reachable from the roots (see :meth :`Tree.roots` for details
2340+ nodes reachable from the roots (see :attr :`Tree.roots` for details
23212341 on which nodes are considered roots). If the ``root`` parameter
23222342 is provided, only the nodes in the subtree rooted at this node
23232343 (including the specified node) will be iterated over. If the
0 commit comments