Skip to content
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

Tree array access. #1320

Merged
merged 1 commit into from
Apr 21, 2021
Merged

Tree array access. #1320

merged 1 commit into from
Apr 21, 2021

Conversation

jeromekelleher
Copy link
Member

WIP for #1299

Trickier than I thought because of the circular references between the array and the Tree object, which owns the memory.

@jeromekelleher jeromekelleher marked this pull request as draft April 19, 2021 16:04
@codecov
Copy link

codecov bot commented Apr 19, 2021

Codecov Report

Merging #1320 (8750471) into main (38ec5ae) will increase coverage by 0.01%.
The diff coverage is 98.48%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1320      +/-   ##
==========================================
+ Coverage   93.80%   93.82%   +0.01%     
==========================================
  Files          26       26              
  Lines       22143    22209      +66     
  Branches     1013     1013              
==========================================
+ Hits        20772    20837      +65     
- Misses       1338     1339       +1     
  Partials       33       33              
Flag Coverage Δ
c-tests 92.44% <ø> (ø)
lwt-tests 92.97% <ø> (ø)
python-c-tests 95.15% <98.48%> (+0.01%) ⬆️
python-tests 98.86% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
python/_tskitmodule.c 91.51% <97.91%> (+0.06%) ⬆️
python/tskit/trees.py 97.93% <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 38ec5ae...8750471. Read the comment docs.

@jeromekelleher jeromekelleher force-pushed the tree_arrays branch 3 times, most recently from c7098ce to 668f762 Compare April 20, 2021 08:56
@jeromekelleher
Copy link
Member Author

jeromekelleher commented Apr 20, 2021

Looks like this is working well. I think it's probably a good idea to add the flags_array and time_array to the Tree class also, since these are things we'll often be using in low-level algorithms, and it's a faff (and currently copy-ful, semantics-wise) to do this via the tree sequence tables arrays.

Should we go ahead and merge this much, and try it out for a bit before documenting, or go ahead and document it now and be done with it? I doubt we can change much here, it's pretty much a done-deal I think.

@benjeffery, any thoughts?

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.

This is awesome stuff, couple of small comments.

I wonder about the _array naming though. Would left_children, parents etc. fit more with our existing names as we don't put type information in names normally?

python/tests/test_highlevel.py Show resolved Hide resolved
python/tests/test_lowlevel.py Show resolved Hide resolved
python/tests/test_lowlevel.py Show resolved Hide resolved
python/tests/test_highlevel.py Show resolved Hide resolved
@benjeffery
Copy link
Member

Should we go ahead and merge this much, and try it out for a bit before documenting, or go ahead and document it now and be done with it? I doubt we can change much here, it's pretty much a done-deal I think.

@benjeffery, any thoughts?

Lets merge this, then file issues under 0.3.6 for time_array and flags_array and the docs. I'm happy to pick those up if I get to them before you.

@jeromekelleher
Copy link
Member Author

I wonder about the _array naming though. Would left_children, parents etc. fit more with our existing names as we don't put type information in names normally?

It's a bit awkward, I agree, but I'm not sure there's much choice. If we were starting again I'd get rid of the parent(u) etc functions and use these arrays instead. But, that ship has sailed, so parent_array seems like the least bad option. I don't want to use parents because this will be break with the convention that array names are singular. Also, I think it would be confusing if we had tree.left_children[u] and tree.left_child(u) giving the same thing.

@jeromekelleher
Copy link
Member Author

(Thanks for the review btw, will update later)

@jeromekelleher jeromekelleher marked this pull request as ready for review April 20, 2021 17:26
@jeromekelleher
Copy link
Member Author

OK, updated and documented. @petrelharp, fancy taking a quick look?

(I finally figured out how to make repeated bits of text in RST: this would come in handy for the stats API!)

Closes tskit-dev#1299

Also refresh links in docs/conf.py.
@@ -1,3 +1,11 @@
.. |tree_array_warning| replace:: This is a high-performance interface which
Copy link
Contributor

Choose a reason for hiding this comment

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

woah nice

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah!

@benjeffery benjeffery added the AUTOMERGE-REQUESTED Ask Mergify to merge this PR label Apr 21, 2021
@mergify mergify bot merged commit 2ae61bb into tskit-dev:main Apr 21, 2021
@mergify mergify bot removed the AUTOMERGE-REQUESTED Ask Mergify to merge this PR label Apr 21, 2021
@petrelharp
Copy link
Contributor

I did look at this, btw - looks good.

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