-
Notifications
You must be signed in to change notification settings - Fork 79
Flesh out examples and add docs to LWT #1004
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
Conversation
|
@jeromekelleher Still draft as I assume we want docstrings - but thought it worth you having a look at the C Python code I added to the examples as I likely missed a detail or more standard way of doing something! |
|
📖 Docs for this PR can be previewed here |
Codecov Report
@@ Coverage Diff @@
## main #1004 +/- ##
==========================================
- Coverage 93.72% 93.68% -0.05%
==========================================
Files 26 26
Lines 20937 20985 +48
Branches 875 875
==========================================
+ Hits 19623 19659 +36
- Misses 1277 1289 +12
Partials 37 37
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
jeromekelleher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. What would be really super-useful here would be an example of how to use the lwt interface with Cython - but maybe we don't want to get into this.
2a09976 to
220e105
Compare
|
@jeromekelleher I've made some changes and fleshed out the example to actually build a tree sequence. I've also removed the creating of a table collection on the C side as we should discourage this. |
jeromekelleher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, some minor nits
|
@jeromekelleher fixed up. |
|
📖 Docs for this PR can be previewed here |
Ah-ha the bot thinks there are doc changes as it is comparing to |
|
@terhorst We've done some work on the Python C extension interface examples and docs here - would you mind seeing if it makes sense? We'll be doing a cython example too eventually. |
d0c6680 to
e18b369
Compare
e18b369 to
cf31f4f
Compare
Hi @benjeffery, sorry, I mentally filed this thread away to respond ... and then promptly threw the filing cabinet out the window ;) In short, I think this is great! Super helpful for what I wanted to accomplish. The only missing piece of the puzzle for me was Cython integration. Cython automatically generates What I ended up doing was creating an extremely minimal C module, say The key is being able to access the table collection pointer from Cython code. Once that's done, you can call all the rest of the |
|
Awesome, thanks for the update @terhorst! Do you have a link to the code please? We'd like to make a minimal example so that others can benefit from your work here! |
|
Sure, a minimal example is to define the LightweightTreeSequence module via https://github.com/terhorst/xsmc/blob/arg/src/_lwtc.c (essentially your example code with all the nonessentials stripped out), and then call it as so: https://github.com/terhorst/xsmc/blob/arg/xsmc/_viterbi.pyx#L154-L157 Note that you'll need to have defined all the various tskit headers; that happens here: |
|
@terhorst Great stuff, is there any chance you have the time to polish the code you've linked to into a minimal example in the tskit codebase? No worries if not! |
|
Here is a Cythonized version of one of the C API examples from the docs: |
|
This looks great, thanks @terhorst! @benjeffery, what's best way of linking this into our docs? Would it be best to get a copy into the tskit repo so we can make sure we don't break it (like the current C example?) |
|
Moving the discussion to #1124 so we don't lose track of it. |
Description
Adds fleshed out examples to the example module and some docs to the README. Not finished yet as I assume we want doc strings on everything?
Fixes #864
PR Checklist: