Skip to content

check for error when indexes=None - #315

Merged
jeromekelleher merged 2 commits into
tskit-dev:masterfrom
petrelharp:default_indexes
Aug 21, 2019
Merged

jeromekelleher merged 2 commits into
tskit-dev:masterfrom
petrelharp:default_indexes

Conversation

@petrelharp

Copy link
Copy Markdown
Contributor

We do have sensible behavior when indexes=None, but we weren't checking that this made sense given the sample_sets passed in. This does that.

@petrelharp

Copy link
Copy Markdown
Contributor Author

Recap here: currently for all sample set statistics with k > 1, indexes=None gives you the same as indexes=[(0, 1, ..., k)]. I think this makes sense, but only if there are exactly k statistics. The change for #250 made Fst agree with this convention.

Over in #313, @jeromekelleher wrote:

maybe this is an argument for dropping the default indexes value for Fst until after 0.2.0? The way I'm thinking about it at the moment is that post 0.2.0 we can possibly refine the semantics at bit such that the dimensions of your arguments determines the dimensions of your output. So, for example, we'd have

ts.diversity([ts.samples()])   ->   [x]
ts.diversity(ts.samples())     ->   x

Here, the user is giving clear information that they're only interested in one sample set in the second example, so we strip off the first dimension and just return the value. Possibly, the right behaviour then is for ts.diversity() to return x also. I'm not sure how this interacts with the indexes argument, but I'm not sure I want to tie us down to something without thinking it through properly either.

So, the question is, do we want to remove default indexes entirely, for now, to think this through better, later?

@jeromekelleher

Copy link
Copy Markdown
Member

This is sensible behaviour, I like it.

So, the question is, do we want to remove default indexes entirely, for now, to think this through better, later?

I'll have a look tomorrow morning and come back with a proposal.

@petrelharp

Copy link
Copy Markdown
Contributor Author

The natural proposal is that if indexes=None then we drop a dimension. I've talked this through with @attrna and I think it makes sense. So, the output would have len(output.shape) equal to (indexes is None) + (windows is None) + (mode == "node").

My main worry was: Suppose you have a script that computes statistics over a bunch of different chocies of windows, or different choices of indexes. You do not want to get outputs of different dimensions. But, this could not happen, unless you put None in your list of choices of windows, for some reason.

In fact, this "dropping dimensions" would be somewhat helpful. Suppose that I want to plot a horizontal line at the genome-wide divergence value:

div = ts.divergence([[0, 1], [2,3]])
ax.axhline(div[0][0])

But, even though I know that div will be a 1 x 1 array, I worry that it's actually got more than one value that I'm ignoring. However, if we drop dimensions automatically, I'd get to do just

ax.axhline(div)

and I know that my [0][0] isn't dropping any information.

@codecov

codecov Bot commented Aug 21, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #315 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #315      +/-   ##
==========================================
+ Coverage   86.42%   86.42%   +<.01%     
==========================================
  Files          20       20              
  Lines       14098    14100       +2     
  Branches     2770     2771       +1     
==========================================
+ Hits        12184    12186       +2     
  Misses        987      987              
  Partials      927      927
Flag Coverage Δ
#c_tests 87.47% <100%> (ø) ⬆️
#python_c_tests 90.27% <100%> (ø) ⬆️
#python_tests 99.23% <100%> (ø) ⬆️
Impacted Files Coverage Δ
python/tskit/trees.py 98.64% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f4c367c...a111cd8. Read the comment docs.

@jeromekelleher

Copy link
Copy Markdown
Member

This is a sensible update, so I'm going to merge it. I'll then bring #313 up to date with the full proposal for dimension stripping and we can see where we are from there.

@jeromekelleher
jeromekelleher merged commit 23fa1a8 into tskit-dev:master Aug 21, 2019
@petrelharp
petrelharp deleted the default_indexes branch April 15, 2020 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants