Skip to content

Commit

Permalink
Override VariantData.from_tree_sequence
Browse files Browse the repository at this point in the history
Fixes #915
  • Loading branch information
hyanwong authored and mergify[bot] committed Sep 5, 2024
1 parent 788d4df commit 89b4ca0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/test_variantdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,3 +757,9 @@ def test_empty_alleles_not_at_end(self, tmp_path):
samples = tsinfer.VariantData(path, "variant_ancestral_allele")
with pytest.raises(ValueError, match="Empty alleles must be at the end"):
tsinfer.infer(samples)

def test_unimplemented_from_tree_sequence(self):
# NB we should reimplement something like this functionality.
# Requires e.g. https://github.com/tskit-dev/tsinfer/issues/924
with pytest.raises(NotImplementedError):
tsinfer.VariantData.from_tree_sequence(None)
4 changes: 4 additions & 0 deletions tsinfer/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2785,6 +2785,10 @@ def _all_haplotypes(self, sites=None, recode_ancestral=None, samples_slice=None)
sample_index += 1
assert sample_index == samples_slice[1]

@classmethod
def from_tree_sequence(*args, **kwargs):
raise NotImplementedError("This method is not implemented for VariantData")


@attr.s(order=False, eq=False)
class Ancestor:
Expand Down

0 comments on commit 89b4ca0

Please sign in to comment.