Skip to content

Test various functions with "empty" trees / tree sequences #943

Closed as not planned

Description

@hyanwong

Functions like Tree.draw_text() and TreeSequence.draw_text() fail at the moment with ValueError: negative dimensions are not allowed if there are no edges, e.g.

tskit.TableCollection(1).tree_sequence().first().draw_text()

And there's no trivial way to create empty trees/tree sequences: you have to go via a TableCollection as in the example above. This makes me think that we haven't been testing many of our functions against these instances. It might be useful to feed such empty instances into all the functions / methods that deal with Trees or TreeSequences. I wonder if this can be done automatically somehow?

Activity

  1. jeromekelleher commented on Oct 28, 2020

    @jeromekelleher
    Member

    A lot of the methods are being tested on an empty/null tree sequence, but it's not systematic. I guess we should add this to the list of example topologies when we're making the set of standard fixtures for pytest.

    I think we should test drawing functions in a separate PR (the pattern there is clear - add a test for this case).

  2. hyanwong commented on Oct 28, 2020

    @hyanwong
    MemberAuthor

    Yep - I just noticed that there was an empty TS in test_highlevel.py::get_example_tree_sequences which I moved to tsutil.py in #931 . So perhaps it's just the drawing code. Having a standard set of examples would be useful, which is why I moved the functions in that PR, but we probably need something more systematic, as you say.

  3. added
    Infrastructure and tools
    Python API
    on Nov 2, 2020
  4. added
    future
    on Jun 12, 2025
  5. benjeffery commented on Jun 12, 2025

    @benjeffery
    Member

    Closing for inactivity and labelling "future", please re-open if you plan to work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Infrastructure and toolsPython APIfuture

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions