Skip to content

Commit 0517732

Browse files
committed
TreeSequence.tables returns ImmutableTableCollection
1 parent 576fde3 commit 0517732

13 files changed

+1145
-282
lines changed

python/lwt_interface/dict_encoding_testlib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def verify(self, tables):
132132

133133
def test_simple(self):
134134
ts = msprime.simulate(10, mutation_rate=1, random_seed=2)
135-
self.verify(ts.tables)
135+
self.verify(ts.dump_tables())
136136

137137
def test_empty(self):
138138
tables = tskit.TableCollection(sequence_length=1)
@@ -152,7 +152,7 @@ def test_sequence_length(self):
152152
ts = msprime.simulate(
153153
10, recombination_rate=0.1, mutation_rate=1, length=0.99, random_seed=2
154154
)
155-
self.verify(ts.tables)
155+
self.verify(ts.dump_tables())
156156

157157
def test_migration(self):
158158
pop_configs = [msprime.PopulationConfiguration(5) for _ in range(2)]
@@ -164,7 +164,7 @@ def test_migration(self):
164164
record_migrations=True,
165165
random_seed=1,
166166
)
167-
self.verify(ts.tables)
167+
self.verify(ts.dump_tables())
168168

169169
def test_example(self, tables):
170170
tables.metadata_schema = tskit.MetadataSchema(

python/tests/test_genotypes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ def test_nonbinary_trees(self):
863863
def test_acgt_mutations(self):
864864
ts = msprime.simulate(10, mutation_rate=10)
865865
assert ts.num_sites > 0
866-
tables = ts.tables
866+
tables = ts.dump_tables()
867867
sites = tables.sites
868868
mutations = tables.mutations
869869
sites.set_columns(
@@ -883,23 +883,23 @@ def test_acgt_mutations(self):
883883

884884
def test_fails_multiletter_mutations(self):
885885
ts = msprime.simulate(10, random_seed=2)
886-
tables = ts.tables
886+
tables = ts.dump_tables()
887887
tables.sites.add_row(0, "ACTG")
888888
tsp = tables.tree_sequence()
889889
with pytest.raises(TypeError):
890890
list(tsp.haplotypes())
891891

892892
def test_fails_deletion_mutations(self):
893893
ts = msprime.simulate(10, random_seed=2)
894-
tables = ts.tables
894+
tables = ts.dump_tables()
895895
tables.sites.add_row(0, "")
896896
tsp = tables.tree_sequence()
897897
with pytest.raises(TypeError):
898898
list(tsp.haplotypes())
899899

900900
def test_nonascii_mutations(self):
901901
ts = msprime.simulate(10, random_seed=2)
902-
tables = ts.tables
902+
tables = ts.dump_tables()
903903
tables.sites.add_row(0, chr(169)) # Copyright symbol
904904
tsp = tables.tree_sequence()
905905
with pytest.raises(TypeError):

python/tests/test_highlevel.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ def verify_edgesets(self, ts):
12921292
tskit.Edge(edgeset.left, edgeset.right, edgeset.parent, child)
12931293
)
12941294
# squash the edges.
1295-
t = ts.dump_tables().nodes.time
1295+
t = ts.tables.nodes.time
12961296
new_edges.sort(key=lambda e: (t[e.parent], e.parent, e.child, e.left))
12971297

12981298
squashed = []
@@ -1916,24 +1916,20 @@ def test_load_tables(self, ts):
19161916
with pytest.raises(
19171917
_tskit.LibraryError, match="Table collection must be indexed"
19181918
):
1919-
assert tskit.TreeSequence.load_tables(tables).dump_tables().has_index()
1919+
assert tskit.TreeSequence.load_tables(tables).tables.has_index()
19201920

19211921
# Tables not in tc, but rebuilt
1922-
assert (
1923-
tskit.TreeSequence.load_tables(tables, build_indexes=True)
1924-
.dump_tables()
1925-
.has_index()
1926-
)
1922+
assert tskit.TreeSequence.load_tables(
1923+
tables, build_indexes=True
1924+
).tables.has_index()
19271925

19281926
tables.build_index()
19291927
# Tables in tc, not rebuilt
1930-
assert (
1931-
tskit.TreeSequence.load_tables(tables, build_indexes=False)
1932-
.dump_tables()
1933-
.has_index()
1934-
)
1928+
assert tskit.TreeSequence.load_tables(
1929+
tables, build_indexes=False
1930+
).tables.has_index()
19351931
# Tables in tc, and rebuilt
1936-
assert tskit.TreeSequence.load_tables(tables).dump_tables().has_index()
1932+
assert tskit.TreeSequence.load_tables(tables).tables.has_index()
19371933

19381934
@pytest.mark.parametrize("ts", tsutil.get_example_tree_sequences())
19391935
def test_html_repr(self, ts):
@@ -1958,14 +1954,14 @@ def test_bad_provenance(self, ts_fixture):
19581954
assert "Could not parse provenance" in ts._repr_html_()
19591955

19601956
def test_provenance_summary_html(self, ts_fixture):
1961-
tables = ts_fixture.tables
1957+
tables = ts_fixture.dump_tables()
19621958
for _ in range(20):
19631959
# Add a row with isotimestamp
19641960
tables.provenances.add_row("foo", "bar")
19651961
assert "... 15 more" in tables.tree_sequence()._repr_html_()
19661962

19671963
def test_html_repr_limit(self, ts_fixture):
1968-
tables = ts_fixture.tables
1964+
tables = ts_fixture.dump_tables()
19691965
d = {n: n for n in range(50)}
19701966
d[0] = "N" * 200
19711967
tables.metadata = d
@@ -2656,7 +2652,8 @@ def verify_tables_api_equality(self, ts):
26562652
tables = ts.dump_tables()
26572653
tables.simplify(samples=samples)
26582654
tables.assert_equals(
2659-
ts.simplify(samples=samples).tables, ignore_timestamps=True
2655+
ts.simplify(samples=samples).dump_tables(),
2656+
ignore_timestamps=True,
26602657
)
26612658

26622659
@pytest.mark.parametrize("ts", tsutil.get_example_tree_sequences())
@@ -4012,7 +4009,7 @@ def test_first_last(self):
40124009

40134010
def test_eq_different_tree_sequence(self):
40144011
ts = msprime.simulate(4, recombination_rate=1, length=2, random_seed=42)
4015-
copy = ts.tables.tree_sequence()
4012+
copy = ts.dump_tables().tree_sequence()
40164013
for tree1, tree2 in zip(ts.aslist(), copy.aslist()):
40174014
assert tree1 != tree2
40184015

python/tests/test_ibd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def test_within_between_mutually_exclusive(self, ts):
275275

276276
@pytest.mark.parametrize("ts", example_ts())
277277
def test_tables_interface(self, ts):
278-
ibd_tab = ts.tables.ibd_segments(store_segments=True)
278+
ibd_tab = ts.dump_tables().ibd_segments(store_segments=True)
279279
ibd_ts = ts.ibd_segments(store_segments=True)
280280
assert ibd_tab == ibd_ts
281281

0 commit comments

Comments
 (0)