Skip to content

Commit a0377fa

Browse files
committed
union doc clarification: closes tskit-dev#3168
1 parent c86884d commit a0377fa

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7402,7 +7402,13 @@ 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 nodes already in ``self``.
7408+
7409+
If the resulting tree sequence is invalid (for instance, a node is
7410+
specified to have two distinct parents on the same interval),
7411+
an error will be raised.
74067412
74077413
Note that this operation also sorts the resulting tables, so the
74087414
resulting tree sequence may not be equal to ``self`` even if nothing

0 commit comments

Comments
 (0)