-
Notifications
You must be signed in to change notification settings - Fork 79
Tolerate invalid parents when computing mutation parents #3309
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3540,6 +3540,34 @@ def test_table_references(self): | |
| assert str(populations) == before_populations | ||
| assert str(provenances) == before_provenances | ||
|
|
||
| def test_compute_mutation_parents_ignores_existing_values(self): | ||
| tables = tskit.TableCollection(sequence_length=1.0) | ||
| parent = tables.nodes.add_row(time=1.0) | ||
| child = tables.nodes.add_row(time=0, flags=tskit.NODE_IS_SAMPLE) | ||
| tables.edges.add_row(left=0.0, right=1.0, parent=parent, child=child) | ||
| site = tables.sites.add_row(position=0.0, ancestral_state="A") | ||
| tables.mutations.add_row(site=site, node=child, derived_state="C") | ||
| tables.build_index() | ||
| tables.mutations.parent[:] = 42 | ||
| tables.compute_mutation_parents() | ||
| assert tables.mutations.parent[0] == tskit.NULL | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another test checking the parent data is preserved on error There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if possible we should check the data is preserved on error even if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| def test_compute_mutation_parents_restores_on_index_error(self): | ||
| tables = tskit.TableCollection(sequence_length=1.0) | ||
| parent = tables.nodes.add_row(time=1.0) | ||
| child = tables.nodes.add_row(time=0, flags=tskit.NODE_IS_SAMPLE) | ||
| tables.edges.add_row(left=0.0, right=1.0, parent=parent, child=child) | ||
| site = tables.sites.add_row(position=0.0, ancestral_state="A") | ||
| tables.mutations.add_row(site=site, node=child, derived_state="C") | ||
|
|
||
| mutation_columns = tables.mutations.asdict() | ||
| mutation_columns["parent"] = np.array([123], dtype=np.int32) | ||
| tables.mutations.set_columns(**mutation_columns) | ||
|
|
||
| with pytest.raises(tskit.LibraryError, match="TSK_ERR_TABLES_NOT_INDEXED"): | ||
| tables.compute_mutation_parents() | ||
| assert tables.mutations.parent[0] == 123 | ||
|
|
||
| def test_str(self): | ||
| ts = msprime.simulate(10, random_seed=1) | ||
| tables = ts.tables | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.