tskit icon indicating copy to clipboard operation
tskit copied to clipboard

Adding path function and tests

Open jeremyguez opened this issue 3 years ago • 3 comments
trafficstars

This PR is for adding the path function which outputs the path between nodes u and v. It is needed for the B2 index https://github.com/tskit-dev/tskit/pull/2327 (issue https://github.com/tskit-dev/tskit/pull/2252).

By the way, the path_length function (https://github.com/tskit-dev/tskit/issues/2249 https://github.com/tskit-dev/tskit/pull/2259) is maybe a little too constrained: if the tree has more than one root, the outputs is always inf. However, in non-rooted trees the paths between nodes that have the same root appear to be defined. For the moment, I defined the path function with this same constrain as in the path_length function, so both functions remain consistent.

cc @jeromekelleher

jeremyguez avatar Jun 19 '22 14:06 jeremyguez

Codecov Report

Merging #2350 (91719f2) into main (a1b1e5d) will decrease coverage by 0.00%. The diff coverage is 92.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2350      +/-   ##
==========================================
- Coverage   93.27%   93.27%   -0.01%     
==========================================
  Files          28       28              
  Lines       26768    26793      +25     
  Branches     1217     1224       +7     
==========================================
+ Hits        24969    24992      +23     
- Misses       1766     1767       +1     
- Partials       33       34       +1     
Flag Coverage Δ
c-tests 92.25% <ø> (ø)
lwt-tests 89.05% <ø> (ø)
python-c-tests 71.34% <4.00%> (-0.13%) :arrow_down:
python-tests 98.82% <92.00%> (-0.03%) :arrow_down:

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

Impacted Files Coverage Δ
python/tskit/trees.py 98.18% <92.00%> (-0.09%) :arrow_down:

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 a1b1e5d...91719f2. Read the comment docs.

codecov[bot] avatar Jun 19 '22 15:06 codecov[bot]

By the way, the path_length function (#2249 #2259) is maybe a little too constrained: if the tree has more than one root, the outputs is always inf

I don't think this is true - if you ask for the length of a path that's within a given rooted subtree it'll work fine. We only check to see if the mrca is -1, and don't actually ask anything about multirooted trees in the implementation.

jeromekelleher avatar Jun 20 '22 07:06 jeromekelleher

By the way, the path_length function (#2249 #2259) is maybe a little too constrained: if the tree has more than one root, the outputs is always inf

I don't think this is true - if you ask for the length of a path that's within a given rooted subtree it'll work fine. We only check to see if the mrca is -1, and don't actually ask anything about multirooted trees in the implementation.

Oh yes right, sorry I got mixed up! Thanks for your answer @jeromekelleher.

jeremyguez avatar Jun 20 '22 15:06 jeremyguez