Skip to content

Commit 7bd2633

Browse files
committed
Only time the node constraining step
1 parent ee6795f commit 7bd2633

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

tsdate/core.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def get_modified_ts(self, result, eps):
200200
tables = ts.dump_tables()
201201
nodes = tables.nodes
202202
mutations = tables.mutations
203+
tables.time_units = self.time_units
203204

204205
# Add posterior mean and variance to node/mutation metadata
205206
meta_timing = time.time()
@@ -215,6 +216,8 @@ def get_modified_ts(self, result, eps):
215216
# Constrain node ages for positive branch lengths
216217
constr_timing = time.time()
217218
nodes.time = util.constrain_ages(ts, node_mean_t, eps, self.constr_iterations)
219+
constr_timing -= time.time()
220+
logger.info(f"Constrained node ages in {abs(constr_timing):.2f} seconds")
218221
# Possibly change mutation nodes if phasing singletons
219222
mutations.node = mut_node
220223
# Deal with mutations. These may have had nodes switched by singleton phasing
@@ -227,17 +230,12 @@ def get_modified_ts(self, result, eps):
227230
tables.sort() # need to sort before computing parents and times
228231
tables.build_index()
229232
# If mutation nodes have been switched, we may need to recalculate parents
230-
# As we have zapped the time, mutations on the same edge at the same site
231-
# will ordered using the original mutation order
232233
tables.compute_mutation_parents()
233234
tables.compute_mutation_times()
234235
num_root_muts = np.sum(mutations.time == nodes.time[mutations.node])
235236
logging.info(
236237
f"Set ages of {num_root_muts} nonsegregating mutations to root times."
237238
)
238-
tables.time_units = self.time_units
239-
constr_timing -= time.time()
240-
logger.info(f"Constrained node ages in {abs(constr_timing):.2f} seconds")
241239
if self.provenance_params is not None:
242240
# Note that the time recorded in provenance excludes numba compilation time
243241
provenance.record_provenance(

0 commit comments

Comments
 (0)