Skip to content

Commit

Permalink
Set time_units to generations when exporting to tskit. (#1242)
Browse files Browse the repository at this point in the history
  • Loading branch information
molpopgen authored Dec 5, 2023
1 parent 5742492 commit cacaabf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions fwdpy11/tskit_tools/_dump_tables_to_tskit.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def _dump_tables_to_tskit(
edge_view = np.array(self.tables.edges, copy=False)

tc = tskit.TableCollection(self.tables.genome_length)
tc.time_units = "generations"

tc.metadata_schema = fwdpy11.tskit_tools.metadata_schema.TopLevelMetadata

Expand Down
4 changes: 4 additions & 0 deletions tests/test_tree_sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def setUpClass(self):
max(self.pop.mcounts) == 2 * self.pop.N
), "Nothing fixed, so test case is not helpful"
self.dumped_ts = self.pop.dump_tables_to_tskit()
assert self.dumped_ts.time_units == "generations"

def test_mut_lookup(self):
self.assertEqual(len(self.pop.mut_lookup),
Expand Down Expand Up @@ -853,6 +854,7 @@ def test_mutation_table_contents(self):

def test_dump_to_tskit(self):
ts = self.pop.dump_tables_to_tskit()
assert ts.time_units == "generations"
self.assertEqual(mcounts_comparison(self.pop, ts), True)

def test_binary_round_trip(self):
Expand Down Expand Up @@ -949,6 +951,7 @@ def test_mutation_table_contents(self):

def test_dump_to_tskit(self):
ts = self.pop.dump_tables_to_tskit()
assert ts.time_units == "generations"
self.assertEqual(mcounts_comparison(self.pop, ts), True)

def test_binary_round_trip(self):
Expand Down Expand Up @@ -1479,6 +1482,7 @@ def setUpClass(self):
)
self.amd = np.array(self.pop.ancient_sample_metadata, copy=False)
self.tskit_ts = self.pop.dump_tables_to_tskit()
assert self.tskit_ts.time_units == "generations"

def test_ancient_sample_records(self):
self.assertEqual(len(self.pop.ancient_sample_metadata), self.pop.N)
Expand Down

0 comments on commit cacaabf

Please sign in to comment.