Skip to content

Commit

Permalink
Clarify Tree.samples() behaviour w/ isolated nodes
Browse files Browse the repository at this point in the history
Just to make it clear that this still works when a node is not "in" the tree topology.
  • Loading branch information
hyanwong authored and mergify[bot] committed May 4, 2023
1 parent 7ddcc95 commit be7d84f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions python/tskit/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -2181,9 +2181,12 @@ def _sample_generator(self, u):
def samples(self, u=None):
"""
Returns an iterator over the numerical IDs of all the sample nodes in
this tree that are underneath node ``u``. If ``u`` is a sample, it is
included in the returned iterator. If u is not specified, return all
sample node IDs in the tree.
this tree that are underneath the node with ID ``u``. If ``u`` is a sample,
it is included in the returned iterator. If ``u`` is not a sample, it is
possible for the returned iterator to be empty, for example if ``u`` is an
:meth:`isolated<Tree.is_isolated>` node that is not part of the the current
topology. If u is not specified, return all sample node IDs in the tree
(equivalent to all the sample node IDs in the tree sequence).
If the :meth:`TreeSequence.trees` method is called with
``sample_lists=True``, this method uses an efficient algorithm to find
Expand Down

0 comments on commit be7d84f

Please sign in to comment.