Skip to content

Conversation

@hyanwong
Copy link
Member

Fixes #847

No tests. What, if any, would we like?

@hyanwong hyanwong force-pushed the kwargs-for-tree-accessors branch from 12c83f8 to fdc023c Compare September 11, 2020 15:22
@petrelharp
Copy link
Contributor

It should be easy to put in a quick test that a few of those kwargs are actually having the desired effect? e.g. that the sample lists are there.

Copy link
Member

@benjeffery benjeffery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ok - I want to be very careful that we don't creep to an API full of **kwargs to the point where finding the docs on what you can actually pass in is hard. (Looking at you, matplotlib!)

@petrelharp
Copy link
Contributor

I want to be very careful that we don't creep to an API full of **kwargs to the point where finding the docs on what you can actually pass in is hard.

Oh, god, good point. Can we make sure to stick in something that will produce a link to where the kwargs are actually listed? (is this :class:.Tree or :meth:.TreeSequence.trees?)

@hyanwong
Copy link
Member Author

Oh, god, good point. Can we make sure to stick in something that will produce a link to where the kwargs are actually listed? (is this :class:.Tree or :meth:.TreeSequence.trees?)

Yes, I think this is in the original PR. I linked thew **kwargs info to :class:``Tree`` which is where the init params are listed, I think.

@hyanwong
Copy link
Member Author

I just realised that, actually, the main trees() method should also pass **kwargs to the Trees constructor, instead of explicitly listing the parameters in the definition, because then we don't miss any parameters. For example, the Trees constructor has a new parameter, root_threshold, which you currently can't set when running trees(), and I guess we might want to allow that?

That's independent of the actual documentation of the trees iterator, though. We might well want to leave the parameters listed there, as it's such a commonly used method. Or if not, I guess we would want to give examples?

@benjeffery
Copy link
Member

In my view trees() should explicitly have all arguments listed. There should be a test to check that the two methods have the same signature so when things are added to Tree we add it to trees().

@hyanwong
Copy link
Member Author

In my view trees() should explicitly have all arguments listed. There should be a test to check that the two methods have the same signature so when things are added to Tree we add it to trees().

If we can test for it, that seems a good approach.

@hyanwong hyanwong force-pushed the kwargs-for-tree-accessors branch from fdc023c to e587945 Compare September 15, 2020 14:35
@hyanwong
Copy link
Member Author

In my recent push, I've added the missing root_threshold param to .trees() and a test to check that all the args used to initialise a Tree are present as the first args of ts.tree(). Also added to the tests are some (rather hacky IMO) checks that tracked_samples is passed though correctly. It's hard to test sample_lists, as setting this to True or False simply activates different algorithmic approaches, of different speeds, to the same end result.

I think #851 should be merged first, though, so that we can properly match up the order of parameters in .tree()

@hyanwong hyanwong force-pushed the kwargs-for-tree-accessors branch 2 times, most recently from 0d051a1 to 83554be Compare September 15, 2020 22:22
Additionally, add the missing root_threshold arg to .trees(), placing the deprecated param at the end (since it is
now kw-only, this should not cause a change in behaviour). Fixes tskit-dev#847
@benjeffery benjeffery force-pushed the kwargs-for-tree-accessors branch from 83554be to 1101f95 Compare September 15, 2020 23:49
Copy link
Member

@benjeffery benjeffery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signature test was almost exactly what I was thinking. I've force pushed a small change to make it more explicit. Thanks @hyanwong!

@mergify mergify bot merged commit c8c957c into tskit-dev:master Sep 16, 2020
@hyanwong
Copy link
Member Author

Thanks @benjeffery - you were working late!

@hyanwong hyanwong deleted the kwargs-for-tree-accessors branch September 16, 2020 10:55
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.

Add sample_lists and tracked_samples to .first() , ts.at(), ts.at_index(), ts.seek()

3 participants