Skip to content

Default behaviour for stats dimension #200

Closed

Description

@jeromekelleher

It's a bit inconvenient stripping off empty dimensions from numpy arrays when we do things like

ts.diversity()

I think it might be nice if we automatically strip off empty dimensions in default cases. So, in this example, we'd have

ts.diversity() = A number
ts.diversity(windows=[0, ts.sequence_length]) = [A number]
ts.diveristy([ts.samples()]) = [A number]
ts.diversity(windows=[0, ts.sequence_length]) = [A number]
ts.diveristy([ts.samples()], windows=[0, ts.sequence_length]) = [[A number]]

I think this will generalise to other stats as well. There's no amibiguity as the dimension stripping only happens on default inputs, and if a user wants the extra dimensions they can simply specify these default inputs themselves.

This is seems like a user-friendly option, as it removes a lot of tedious stat[0, 0] accesses when you just want a single value. What do you think @petrelharp?

Activity

  1. petrelharp commented on Jun 10, 2019

    @petrelharp
    Contributor

    Gee, that's a nice, elegant idea. I like it. But: this is tricky. I agree that all the [0][0]s are tedious and counterintuitive but switching output types is also counterintuitive.

    I surveyed some bioinformatics users here (Anastasia), who thinks that (a) people aren't actually going to want to use the defaults all that often, because with the scale of data you have in tree sequences, you'll almost always want across windows and between populations, and (b) the different dimensionalities is confusing. I tend to agree, I think?

    So, I vote to leave it always 2D arrays? (Hm, this proposal was probably made with the node arrays (3D) in mind.)

    I think that if we do want to make this change, the first test should be to write the documentation for it (in docs/stats.rst), and if it's too confusing to explain then to ditch it.

  2. added this to the Python 0.1.6 milestone on Jun 11, 2019
  3. jeromekelleher commented on Aug 23, 2019

    @jeromekelleher
    MemberAuthor

    Closed in #313.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions