Skip to content

Commit 38d6d3f

Browse files
petrelharphyanwong
authored andcommitted
docstring, changelog
1 parent 7245feb commit 38d6d3f

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

python/CHANGELOG.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@
5050
- Add ``Mutation.inherited_state`` property which returns the inherited state
5151
for a single mutation. (:user:`benjeffery`, :pr:`3277`, :issue:`2631`)
5252

53-
- Add `all_mutations` and `all_edges` parameters to `union()`, allowing disjoint unioning
54-
(:user:`petrelharp`, :user:`hyanwong`, :pr:`3283`, :issue:`3181`)
53+
- Add ``all_mutations`` and ``all_edges`` options to ``TreeSequence.union``,
54+
allowing greater flexibility in "disjoint union" situations.
55+
(:user:`hyanwong`, :user:`petrelharp`, :issue:`3181`)
5556

5657
**Bugfixes**
5758

@@ -82,8 +83,8 @@
8283
- Prevent iterating over a ``TopologyCounter``
8384
(:user:`benjeffery` , :pr:`3202`, :issue:`1462`)
8485

85-
- Fix `TreeSequence.concatenate()` to work with internal samples by using the
86-
`all_mutations` and `all_edges` parameters in `union()`
86+
- Fix ``TreeSequence.concatenate()`` to work with internal samples by using the
87+
``all_mutations`` and ``all_edges`` parameters in ``union()``
8788
(:user:`hyanwong`, :pr:`3283`, :issue:`3181`)
8889

8990
**Breaking changes**

python/tskit/trees.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7517,6 +7517,24 @@ def union(
75177517
nodes are in entirely new populations, then you must set up the
75187518
population table first, and then union with ``add_populations=False``.
75197519
7520+
This method makes sense if the "shared" portions of the tree sequences
7521+
are equal; the option ``check_shared_equality`` performs a consistency
7522+
check that this is true. If this check is disabled, it is very easy to
7523+
produce nonsensical results via subtle inconsistencies.
7524+
7525+
The behavior above can be changed by ``all_edges`` and ``all_mutations``.
7526+
If ``all_edges`` is True, then all edges in ``other` are added to
7527+
``self``, instead of only edges adjacent to added nodes. If
7528+
``all_mutations`` is True, then similarly all mutations in ``other``
7529+
are added (not just those on added nodes); furthermore, all sites
7530+
at positions without a site already present are added to ``self``.
7531+
The intended use case for these options is a "disjoint" union,
7532+
where for instance the two tree sequences contain information about
7533+
disjoint segments of the genome (see :meth:`.concatenate`).
7534+
For some such applications it may be necessary to set
7535+
``check_shared_overlap=False`` (but also easier to check for validity
7536+
separately).
7537+
75207538
If the resulting tree sequence is invalid (for instance, a node is
75217539
specified to have two distinct parents on the same interval),
75227540
an error will be raised.

0 commit comments

Comments
 (0)