Skip to content
Merged
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
27 changes: 11 additions & 16 deletions pyslim/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,21 +714,18 @@ def slim_time(ts, time, stage="late"):

def _shift_times(ts, dt):
"""
Add `dt` to the times ago of all nodes, and mutations.
Add `dt` to the times ago of all nodes and mutations.
(Note: migrations not currently supported by simplify,
so not used here.)
"""
tables = ts.dump_tables()
if dt != 0:
tables.nodes.clear()
tables.mutations.clear()
tables.migrations.clear()
for node in ts.nodes():
tables.nodes.append(node.replace(time=node.time + dt))
for mutation in ts.mutations():
tables.mutations.append(mutation.replace(time=mutation.time + dt))
# for mig in ts.migrations():
# tables.migrations.append(mig.replace(time=mig.time + dt))
d = tables.nodes.asdict()
d['time'] += dt
tables.nodes.set_columns(**d)
d = tables.mutations.asdict()
d['time'] += dt
tables.mutations.set_columns(**d)
return tables


Expand Down Expand Up @@ -777,12 +774,10 @@ def set_slim_state(ts, time=0, individuals=None):
md['SLiM']['cycle'] -= time
tables.metadata = md
if individuals is not None:
flags = tables.individuals.flags
flags &= ~INDIVIDUAL_ALIVE
flags[individuals] |= INDIVIDUAL_ALIVE
tables.individuals.clear()
for f, ind in zip(flags, ts.individuals()):
tables.individuals.append(ind.replace(flags=f))
d = tables.individuals.asdict()
d['flags'] &= ~INDIVIDUAL_ALIVE
d['flags'][individuals] |= INDIVIDUAL_ALIVE
tables.individuals.set_columns(**d)
return tables.tree_sequence()


Expand Down