Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 7 additions & 3 deletions python/tskit/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -3816,9 +3816,13 @@ def canonicalise(self, remove_unreferenced=None):
"""
This puts the tables in *canonical* form, imposing a stricter order on the
tables than :ref:`required <sec_valid_tree_sequence_requirements>` for
a valid tree sequence. In particular, the individual
and population tables are sorted by the first node that refers to each
(see :meth:`TreeSequence.subset`). Then, the remaining tables are sorted
a valid tree sequence. In particular, the population table is sorted by
the lowest ID of the nodes that refer to each population, and the
individual table is sorted to ensure that not only are the standard
:ref:`sorting requirements<sec_individual_requirements>` met but
also secondarily sorted by the lowest ID of the nodes
that refer to each individual (see :meth:`TreeSequence.subset`).
The remaining tables are sorted
as in :meth:`.sort`, with the modification that mutations are sorted by
site, then time (if known), then the mutation's node's time, then number
of descendant mutations (ensuring that parent mutations occur before
Expand Down
11 changes: 7 additions & 4 deletions python/tskit/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -7513,10 +7513,13 @@ def subset(
the ancestry of these nodes - for that, see :meth:`.simplify`.

This has the side effect that it may change the order of the nodes,
individuals, populations, and migrations in the tree sequence: the nodes
in the new tree sequence will be in the order provided in ``nodes``, and
both individuals and populations will be ordered by the earliest retained
node that refers to them. (However, ``reorder_populations`` may be set to
individuals, populations, and migrations in the tree sequence. Nodes
in the new tree sequence will be in the order provided in ``nodes``,
populations will be ordered by the lowest ID of the nodes that refer to
them, and individuals will be not only ordered so that
:attr:`~Individual.parents` come before children, but in addition
will be secondarily sorted by the lowest ID of their referring
nodes. (However, ``reorder_populations`` may be set to
False to keep the population table unchanged.)

By default, the method removes all individuals and populations not
Expand Down