Skip to content

Commit 5163dbb

Browse files
committed
mut time
1 parent d13c160 commit 5163dbb

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

python/tests/tsutil.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ def disorder_ts(ts, seed):
715715
derived_state=m.derived_state,
716716
parent=m.parent,
717717
metadata=m.metadata,
718-
# time=m.time,
718+
time=m.time,
719719
)
720720
return tables
721721

@@ -735,10 +735,12 @@ def orig_mut_keys(i, tables, sorted_sites):
735735
return sorted_sites.index(orig_site)
736736

737737

738-
def new_mut_keys(i, tables, sorted_sites):
738+
def new_mut_keys(i, tables, sorted_sites, time_in_key):
739739
orig_site = tables.mutations.site[i]
740+
time = tables.mutations.time[i] if time_in_key else 0
740741
return (
741742
sorted_sites.index(orig_site),
743+
time,
742744
tables.mutations.parent[i],
743745
tables.mutations.node[i],
744746
)
@@ -751,6 +753,7 @@ def py_sort(
751753
tables.edges.clear()
752754
tables.sites.clear()
753755
tables.mutations.clear()
756+
time_in_key = np.all(np.isnan(copy.mutations.time))
754757
sorted_edges = sorted(
755758
range(copy.edges.num_rows), key=lambda x: edge_keys(x, tables=copy)
756759
)
@@ -759,7 +762,9 @@ def py_sort(
759762
)
760763
sorted_muts = sorted(
761764
range(copy.mutations.num_rows),
762-
key=lambda x: mut_keys(x, tables=copy, sorted_sites=sorted_sites),
765+
key=lambda x: mut_keys(
766+
x, tables=copy, sorted_sites=sorted_sites, time_in_key=time_in_key
767+
),
763768
)
764769
for edge_id in sorted_edges:
765770
tables.edges.add_row(
@@ -781,7 +786,7 @@ def py_sort(
781786
copy.mutations[mut_id].derived_state,
782787
copy.mutations[mut_id].parent,
783788
copy.mutations[mut_id].metadata,
784-
# copy.mutations[mut_id].time,
789+
copy.mutations[mut_id].time,
785790
)
786791

787792

0 commit comments

Comments
 (0)