tskit
tskit copied to clipboard
Generic iterator class for trees and variants
Description
Pull out the logic that iterates over trees and variants into a single base class, and allow this class to return a length.
Also allows left, right, copy to be passed to the trees() iterator (to match the variants() iterator), so that we can
iterate over a subset of the genome.
Also implements next() and prev() for trees, to match the variants iterator (they are handy anyway, right?)
Fixes https://github.com/tskit-dev/tskit/issues/2625, https://github.com/tskit-dev/tskit/issues/24
PR Checklist:
- [x] Tests that fully cover new/changed functionality.
- [x] Documentation including tutorial content if appropriate.
- [ ] Changelogs, if there are API changes.
BTW, this renders ts.aslist() a bit obsolete, as you can do ts.trees(copy=True), in the same way you do for variants.