Skip to content

Commit 9d2ff8e

Browse files
authored
improve union docs
1 parent c86884d commit 9d2ff8e

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

python/tests/test_tables.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5047,6 +5047,13 @@ def test_union_empty(self):
50475047
uni.union(empty_tables, [])
50485048
tables.assert_equals(uni, ignore_provenance=True)
50495049

5050+
def test_contradictory_children(self):
5051+
# these are identical
5052+
ts1 = tskit.Tree.generate_comb(2, span=2).tree_sequence
5053+
ts2 = tskit.Tree.generate_comb(2, span=2).tree_sequence
5054+
with pytest.raises(_tskit.LibraryError, match="contradictory children"):
5055+
_ = ts1.union(ts2, node_mapping=[0, 1, -1])
5056+
50505057
def test_noshared_example(self):
50515058
ts1 = self.get_msprime_example(sample_size=3, T=2, seed=9328)
50525059
ts2 = self.get_msprime_example(sample_size=3, T=2, seed=2125)

python/tskit/trees.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7402,7 +7402,14 @@ def union(
74027402
added mutation.
74037403
74047404
By default, populations of newly added nodes are assumed to be new
7405-
populations, and added to the population table as well.
7405+
populations, and added to the population table as well. This can be
7406+
thought of as a "node-wise" union: for instance, it can not be used
7407+
to add new edges between two nodes already in ``self`` or new mutations
7408+
above nodes already in ``self``.
7409+
7410+
If the resulting tree sequence is invalid (for instance, a node is
7411+
specified to have two distinct parents on the same interval),
7412+
an error will be raised.
74067413
74077414
Note that this operation also sorts the resulting tables, so the
74087415
resulting tree sequence may not be equal to ``self`` even if nothing

0 commit comments

Comments
 (0)