From a13e6bb93f5a974ac8a20c965625f3ed336f33c1 Mon Sep 17 00:00:00 2001 From: Ben Jeffery Date: Thu, 22 Jan 2026 16:07:49 +0000 Subject: [PATCH 1/2] tskit 1.0 --- CHANGELOG.md | 2 ++ pyproject.toml | 4 ++-- tsdate/evaluation.py | 2 ++ tsdate/phasing.py | 2 ++ tsdate/util.py | 2 ++ 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be6b8f73..a92a0631 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - Add support for Python 3.13, minimum version is now 3.10. +- Make tsdate compatible with tskit 1.0.0. + ## [0.2.3] - 2025-06-07 **Breaking changes** diff --git a/pyproject.toml b/pyproject.toml index 74186aeb..08665fa1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ classifiers = [ "Topic :: Scientific/Engineering :: Bio-Informatics", ] dependencies = [ - "tskit>=0.5.8", + "tskit>=1.0.0", "numpy", "scipy>=1.13.0", "numba>=0.58.1", @@ -91,7 +91,7 @@ docs = [ "pandas==2.3.2", "stdpopsim==0.3.0", "tsinfer==0.4.1", - "tskit==0.6.4", + "tskit==1.0.0", "jupyter-book==1.0.4.post1", "sphinx-issues==5.0.1", "sphinx-argparse==0.5.2", diff --git a/tsdate/evaluation.py b/tsdate/evaluation.py index b143d4e1..efe56719 100644 --- a/tsdate/evaluation.py +++ b/tsdate/evaluation.py @@ -144,6 +144,8 @@ def remove_edges(ts, edge_id_remove_list): tables.edges.append(e) assert len(new_edges) == 0 tables.sort() + tables.build_index() + tables.compute_mutation_parents() return tables.tree_sequence() diff --git a/tsdate/phasing.py b/tsdate/phasing.py index 102d8746..5dba4d7b 100644 --- a/tsdate/phasing.py +++ b/tsdate/phasing.py @@ -463,4 +463,6 @@ def rephase_singletons(ts, use_node_times=True, random_seed=None): tables.mutations.node = mutations_node tables.mutations.time = mutations_time tables.sort() + tables.build_index() + tables.compute_mutation_parents() return tables.tree_sequence() diff --git a/tsdate/util.py b/tsdate/util.py index 00ca25b0..4ac171d9 100644 --- a/tsdate/util.py +++ b/tsdate/util.py @@ -580,6 +580,8 @@ def split_disjoint_nodes(ts, *, record_provenance=None): # Update the mutations table tables.mutations.node = mutations_node tables.sort() + tables.build_index() + tables.compute_mutation_parents() assert np.array_equal( tables.nodes.time[tables.mutations.node], ts.nodes_time[ts.mutations_node] From e9e577583c26d24a01d4583af67e9a985aa817b4 Mon Sep 17 00:00:00 2001 From: Yan Wong Date: Fri, 23 Jan 2026 12:47:45 +0000 Subject: [PATCH 2/2] Fix failing tests dues to mutation parents --- tests/test_inference.py | 3 +++ tests/utility_functions.py | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_inference.py b/tests/test_inference.py index 3b4d1e39..75527269 100644 --- a/tests/test_inference.py +++ b/tests/test_inference.py @@ -415,6 +415,9 @@ def test_multiple_mutations_same_node_and_pos(self): tables.mutations.add_row(site=s, node=1, derived_state="1", time=1.5) tables.mutations.add_row(site=s, node=1, derived_state="2", time=1) tables.mutations.add_row(site=s, node=1, derived_state="3", time=0.5) + tables.sort() + tables.build_index() + tables.compute_mutation_parents() ts = tsdate.date(tables.tree_sequence(), mutation_rate=1) assert np.all(np.diff(ts.mutations_time) < 0) for m in ts.mutations(): diff --git a/tests/utility_functions.py b/tests/utility_functions.py index 7f0469e1..d2bd3c29 100644 --- a/tests/utility_functions.py +++ b/tests/utility_functions.py @@ -979,9 +979,9 @@ def single_tree_ts_2mutations_n3(): ) mutations = io.StringIO( """\ - site node derived_state - 0 3 1 - 0 1 0 + site node derived_state parent + 0 3 1 -1 + 0 1 0 0 """ ) return tskit.load_text(