Skip to content

Add node traversal methods based on time ordering - #399

Merged
jeromekelleher merged 1 commit into
tskit-dev:masterfrom
benjeffery:246_time_ordered_node_traversal
Nov 6, 2019
Merged

jeromekelleher merged 1 commit into
tskit-dev:masterfrom
benjeffery:246_time_ordered_node_traversal

Conversation

@benjeffery

Copy link
Copy Markdown
Member

Addresses #246 using a very simple implementation as discussed. I went with timeasc and timedesc as the possible values for order= as they seemed to fit the existing values.

@codecov

codecov Bot commented Nov 5, 2019 •

Copy link
Copy Markdown

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #399      +/-   ##
==========================================
+ Coverage   86.52%   86.52%   +<.01%     
==========================================
  Files          20       20              
  Lines       14068    14072       +4     
  Branches     2750     2750              
==========================================
+ Hits        12172    12176       +4     
  Misses        977      977              
  Partials      919      919
Flag Coverage Δ
#c_tests 87.62% <100%> (ø) ⬆️
#python_c_tests 90.38% <100%> (ø) ⬆️
#python_tests 99.25% <100%> (ø) ⬆️
Impacted Files Coverage Δ
python/tskit/trees.py 98.7% <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 002133a...6686495. Read the comment docs.

@benjeffery

Copy link
Copy Markdown
Member Author

One thing I forgot to add - this treats each root separately, so if you call without a node and the tree has more than one root then the sort is only ordered for each root, not globally. This is how the other sort methods work, but I think it might make less sense for time ordering.

@hyanwong

hyanwong commented Nov 5, 2019

Copy link
Copy Markdown
Member

Hi @benjeffery: thanks for getting involved with tskit development. If your head is in the ordering methods, you might like to take a stab at #384 - there are definite use cases for visiting the edges of a tree sequence (rather than the nodes of a tree) in order of (a) child node times and (b) parent node times. In that issue I suggested simply re-ordering the edge table, but since we might want to keep the edge IDs consistent between the two methods, I wonder if providing an order argument to the ts.edges() method might be better?

@jeromekelleher

Copy link
Copy Markdown
Member

This looks great, thanks @benjeffery. I think we'll need some more documentation on what the orders are, but I'll open an issue to track that.

@jeromekelleher
jeromekelleher merged commit 628db5d into tskit-dev:master Nov 6, 2019
@benjeffery
benjeffery deleted the 246_time_ordered_node_traversal branch April 18, 2020 22:59
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.

3 participants