@@ -936,22 +936,23 @@ def constrain_ages_topo(ts, node_times, eps, progress=False):
936936 If node_times violate topology, return increased node_times so that each node is
937937 guaranteed to be older than any of its their children.
938938 """
939- tables = ts .tables
939+ edges_parent = ts .edges_parent
940+ edges_child = ts .edges_child
941+
940942 new_node_times = np .copy (node_times )
941943 # Traverse through the ARG, ensuring children come before parents.
942944 # This can be done by iterating over groups of edges with the same parent
943- new_parent_edge_idx = np .concatenate (
944- (
945- [0 ],
946- np .where (np .diff (tables .edges .parent ) != 0 )[0 ] + 1 ,
947- [tables .edges .num_rows ],
948- )
949- )
950- for edges_start , edges_end in zip (
951- new_parent_edge_idx [:- 1 ], new_parent_edge_idx [1 :]
945+ new_parent_edge_idx = np .where (np .diff (edges_parent ) != 0 )[0 ] + 1
946+ for edges_start , edges_end in tqdm (
947+ zip (
948+ itertools .chain ([0 ], new_parent_edge_idx ),
949+ itertools .chain (new_parent_edge_idx , [len (edges_parent )]),
950+ ),
951+ desc = "Constrain Ages" ,
952+ disable = not progress ,
952953 ):
953- parent = tables . edges . parent [edges_start ]
954- child_ids = tables . edges . child [edges_start :edges_end ] # May contain dups
954+ parent = edges_parent [edges_start ]
955+ child_ids = edges_child [edges_start :edges_end ] # May contain dups
955956 oldest_child_time = np .max (new_node_times [child_ids ])
956957 if oldest_child_time >= new_node_times [parent ]:
957958 new_node_times [parent ] = oldest_child_time + eps
0 commit comments