Repository navigation
Create Python IbdSegmentList and IbdSegment - #1707
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1707 +/- ##
========================================
Coverage 93.36% 93.37%
========================================
Files 27 27
Lines 24251 24363 +112
Branches 1093 1095 +2
========================================
+ Hits 22643 22750 +107
- Misses 1573 1578 +5
Partials 35 35
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
9ff17c9 to
e6a7632
Compare
|
This diff is probably big enough that we should merge it before going ahead with further changes. I'll open a few follow up issues (mostly around documentation). This is nearly the end for the big IBD changes and I think it'll settle down pretty quickly now. |
aff3713 to
cd7ec8f
Compare
|
Nice to get this merged fairly soon - any chance you could take a look through please @gtsambos? |
| result.get(0, 1) | ||
| with pytest.raises(SystemError): | ||
| result.print_state() | ||
| with pytest.raises(SystemError): |
There was a problem hiding this comment.
Is there a reason why these new attributes are uninitialised (as opposed to 0)?
There was a problem hiding this comment.
This is reflecting a tricky detail about how we're managing memory. The low-level IbdSegments class is a thin wrapper around the tsk_ibd_segments_t class in C. We only ever create a new IbdSegments class as a result of calling tables.find_ibd(), which ensures that the memory management is handled correctly. What this test is doing is ensuring that if someone deliberately sidesteps all this, and tries to create an IbdSegments instance manually they don't get a segfault (which they would, if we weren't carefully checking the state of things).
Basically this will never happen, it's just low-level stuff to make sure the memory management is all water tight.
| with pytest.raises(SystemError, match="not initialised"): | ||
| getattr(seglist, attr) | ||
|
|
||
| def test_memory_management(self): |
There was a problem hiding this comment.
I don't understand what this test is doing -- can you explain a bit?
There was a problem hiding this comment.
It's basically the same as the previous comment - we're checking some tricky details about how memory is managed, making sure we don't leak or segfault in odd situations. In this case, the ownership of the underlying memory is being managed by the object that we del, and we're making sure that this object doesn't actually disappear until after all the things that reference it also disappear.
Some background on reference counting in Python might clear things up a bit, if you're interested.
gtsambos
left a comment
There was a problem hiding this comment.
Looks good Jerome! These new classes (esp. the IbdSegment one) look like they'll make this output a lot nicer to work with.
|
@benjeffery, any chance you could have a quick look over this please? |
benjeffery
left a comment
There was a problem hiding this comment.
LGTM!
One paranoia suggestion.
I am running the stress test on this branch, looks good so far but will leave running.
cd7ec8f to
d6dd3fa
Compare
|
Great, thanks @benjeffery. Updated with nice extra paranoia - please merge whenever you're happy. |
Also rename ibd_result to ibd_segments Closes tskit-dev#1708
Decouples the internal library details from the external structure. Also minor fixups in the Python implementation
d6dd3fa to
f808ebf
Compare
This updates the types that we return from the IBD calculations to make them more flexible and renames
find_ibdtoibd_segments