Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set time_units to generations when exporting to tskit. #1242

Merged
merged 1 commit into from Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions fwdpy11/tskit_tools/_dump_tables_to_tskit.py
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
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