Skip to content
Draft
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
658 changes: 121 additions & 537 deletions python/_tskitmodule.c

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions python/lwt_interface/dict_encoding_testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def verify(self, tables):

def test_simple(self):
ts = msprime.simulate(10, mutation_rate=1, random_seed=2)
self.verify(ts.tables)
self.verify(ts.dump_tables())

def test_empty(self):
tables = tskit.TableCollection(sequence_length=1)
Expand All @@ -152,7 +152,7 @@ def test_sequence_length(self):
ts = msprime.simulate(
10, recombination_rate=0.1, mutation_rate=1, length=0.99, random_seed=2
)
self.verify(ts.tables)
self.verify(ts.dump_tables())

def test_migration(self):
pop_configs = [msprime.PopulationConfiguration(5) for _ in range(2)]
Expand All @@ -164,7 +164,7 @@ def test_migration(self):
record_migrations=True,
random_seed=1,
)
self.verify(ts.tables)
self.verify(ts.dump_tables())

def test_example(self, tables):
tables.metadata_schema = tskit.MetadataSchema(
Expand Down
8 changes: 4 additions & 4 deletions python/tests/test_genotypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ def test_nonbinary_trees(self):
def test_acgt_mutations(self):
ts = msprime.simulate(10, mutation_rate=10)
assert ts.num_sites > 0
tables = ts.tables
tables = ts.dump_tables()
sites = tables.sites
mutations = tables.mutations
sites.set_columns(
Expand All @@ -883,23 +883,23 @@ def test_acgt_mutations(self):

def test_fails_multiletter_mutations(self):
ts = msprime.simulate(10, random_seed=2)
tables = ts.tables
tables = ts.dump_tables()
tables.sites.add_row(0, "ACTG")
tsp = tables.tree_sequence()
with pytest.raises(TypeError):
list(tsp.haplotypes())

def test_fails_deletion_mutations(self):
ts = msprime.simulate(10, random_seed=2)
tables = ts.tables
tables = ts.dump_tables()
tables.sites.add_row(0, "")
tsp = tables.tree_sequence()
with pytest.raises(TypeError):
list(tsp.haplotypes())

def test_nonascii_mutations(self):
ts = msprime.simulate(10, random_seed=2)
tables = ts.tables
tables = ts.dump_tables()
tables.sites.add_row(0, chr(169)) # Copyright symbol
tsp = tables.tree_sequence()
with pytest.raises(TypeError):
Expand Down
31 changes: 14 additions & 17 deletions python/tests/test_highlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ def verify_edgesets(self, ts):
tskit.Edge(edgeset.left, edgeset.right, edgeset.parent, child)
)
# squash the edges.
t = ts.dump_tables().nodes.time
t = ts.tables.nodes.time
new_edges.sort(key=lambda e: (t[e.parent], e.parent, e.child, e.left))

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

# Tables not in tc, but rebuilt
assert (
tskit.TreeSequence.load_tables(tables, build_indexes=True)
.dump_tables()
.has_index()
)
assert tskit.TreeSequence.load_tables(
tables, build_indexes=True
).tables.has_index()

tables.build_index()
# Tables in tc, not rebuilt
assert (
tskit.TreeSequence.load_tables(tables, build_indexes=False)
.dump_tables()
.has_index()
)
assert tskit.TreeSequence.load_tables(
tables, build_indexes=False
).tables.has_index()
# Tables in tc, and rebuilt
assert tskit.TreeSequence.load_tables(tables).dump_tables().has_index()
assert tskit.TreeSequence.load_tables(tables).tables.has_index()

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

def test_provenance_summary_html(self, ts_fixture):
tables = ts_fixture.tables
tables = ts_fixture.dump_tables()
for _ in range(20):
# Add a row with isotimestamp
tables.provenances.add_row("foo", "bar")
assert "... 15 more" in tables.tree_sequence()._repr_html_()

def test_html_repr_limit(self, ts_fixture):
tables = ts_fixture.tables
tables = ts_fixture.dump_tables()
d = {n: n for n in range(50)}
d[0] = "N" * 200
tables.metadata = d
Expand Down Expand Up @@ -2656,7 +2652,8 @@ def verify_tables_api_equality(self, ts):
tables = ts.dump_tables()
tables.simplify(samples=samples)
tables.assert_equals(
ts.simplify(samples=samples).tables, ignore_timestamps=True
ts.simplify(samples=samples).dump_tables(),
ignore_timestamps=True,
)

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

def test_eq_different_tree_sequence(self):
ts = msprime.simulate(4, recombination_rate=1, length=2, random_seed=42)
copy = ts.tables.tree_sequence()
copy = ts.dump_tables().tree_sequence()
for tree1, tree2 in zip(ts.aslist(), copy.aslist()):
assert tree1 != tree2

Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_ibd.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def test_within_between_mutually_exclusive(self, ts):

@pytest.mark.parametrize("ts", example_ts())
def test_tables_interface(self, ts):
ibd_tab = ts.tables.ibd_segments(store_segments=True)
ibd_tab = ts.dump_tables().ibd_segments(store_segments=True)
ibd_ts = ts.ibd_segments(store_segments=True)
assert ibd_tab == ibd_ts

Expand Down
Loading