Skip to content

Implement Tree.has_isolated_samples #1908

@jeromekelleher

Description

@jeromekelleher

The topological definition of missing data is that we have an isolated sample (a sample node with no children or parents). #1894 added a quick definition of this to the Python API, but we should implement it in C and test it out to make sure it's correct in various corner cases.

   def has_isolated_samples(self):
          for root in self.roots:
            if self.left_child(root) == NULL:
                return True
        return False

Some that occur to me:

  1. Is this correct when we have a tree sequence with a single sample node and no edges? (Yes, I think?)
  2. What about the empty tree sequence? (Do we get trees empty trees returned by trees()?)
  3. What if we have non-sample topology below this root? Is this considered isolated or not?

Metadata

Metadata

Assignees

No one assigned

    Labels

    C APIIssue is about the C APIPython APIIssue is about the Python APIfutureIssues that are closed as they are not planned in the medium-term, but which are still desirable.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions