Skip to content

Add ts.coiterate method #1022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 23, 2020
Merged

Add ts.coiterate method #1022

merged 1 commit into from
Nov 23, 2020

Conversation

hyanwong
Copy link
Member

@hyanwong hyanwong commented Nov 20, 2020

Fixes #1021

@hyanwong
Copy link
Member Author

@benjeffery - this is failing because sphinx can't find the Interval class, which is actually defined right at the top of the trees.py file. I can't figure out why it doesn't work, when sphinx finds the Tree class just fine. Might you have time to have a look?

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.

A few nits and suggestions. The kwargs functionality is not being tested yet. There are also some failing tests that refer to the old tsutil version of this. The doc build is failing as Interval is not documented, i.e. python-api.rst doesn't contain .. autoclass:: Interval. The class itself is also missing docstrings.

@hyanwong
Copy link
Member Author

A few nits and suggestions. The kwargs functionality is not being tested yet. There are also some failing tests that refer to the old tsutil version of this. The doc build is failing as Interval is not documented, i.e. python-api.rst doesn't contain .. autoclass:: Interval. The class itself is also missing docstrings.

All great suggestions, thanks @benjeffery . I didn't realise that documentation was required to link (although I guess that's obvious, really), Should I document Interval, even though it's trivial?

@benjeffery
Copy link
Member

Should I document Interval, even though it's trivial?

If we're returning iterators using it then I guess it goes in the "Simple Container Classes" section.

@AdminBot-tskit
Copy link
Collaborator

📖 Docs for this PR can be previewed here

@codecov
Copy link

codecov bot commented Nov 21, 2020

Codecov Report

Merging #1022 (06b8be6) into main (fca033d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1022   +/-   ##
=======================================
  Coverage   93.68%   93.69%           
=======================================
  Files          26       26           
  Lines       20829    20846   +17     
  Branches      855      859    +4     
=======================================
+ Hits        19514    19531   +17     
  Misses       1277     1277           
  Partials       38       38           
Flag Coverage Δ
c-tests 92.49% <ø> (ø)
lwt-tests 93.57% <ø> (ø)
python-c-tests 94.86% <100.00%> (+<0.01%) ⬆️
python-tests 98.57% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
python/tskit/trees.py 97.40% <100.00%> (+0.02%) ⬆️

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 fca033d...06b8be6. Read the comment docs.

@hyanwong
Copy link
Member Author

All done. Thanks @benjeffery

Copy link
Member

@jeromekelleher jeromekelleher left a comment

Choose a reason for hiding this comment

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

Very nice, thanks @hyanwong. A couple of small tweaks and we're good to merge.

ts1 = msprime.simulate(4, random_seed=1, length=2)
ts2 = msprime.simulate(4, random_seed=1)
with pytest.raises(ValueError, match="equal sequence length"):
next(ts1.coiterate(ts2))
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't need the next here I think

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we do. If I remove it, we don't get the error raised, because we don't actually start the generator going?

Copy link
Member

Choose a reason for hiding this comment

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

Generator functions are only executed when after the first next so yeah, we do need it.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, my bad.

@@ -3850,6 +3863,43 @@ def trees(
)
return TreeIterator(tree)

def coiterate(self, other, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

Actually, might make more sense to put this next to the trees iterator in the file? It's nice to keep methods somewhat grouped by topic.

Copy link
Member Author

Choose a reason for hiding this comment

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

Erm. That's where it is, isn't it?

Copy link
Member

Choose a reason for hiding this comment

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

Yep, so it is. GitHub's way of showing context is a bit weird sometimes

@hyanwong hyanwong force-pushed the coiterate branch 2 times, most recently from 39eadef to 79be302 Compare November 23, 2020 09:45
@benjeffery benjeffery added the AUTOMERGE-REQUESTED Ask Mergify to merge this PR label Nov 23, 2020
@mergify mergify bot merged commit cc50d28 into tskit-dev:main Nov 23, 2020
@mergify mergify bot removed the AUTOMERGE-REQUESTED Ask Mergify to merge this PR label Nov 23, 2020
@hyanwong hyanwong deleted the coiterate branch November 23, 2020 11:07
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 TreeSequence.coiterate(other, **kwargs) method
4 participants