Skip to content

constify tree C API, but short of changing tsk_tree_t type and stats functions - #920

Merged
mergify[bot] merged 1 commit into
tskit-dev:mainfrom
castedo:pr/no_change_tsk_tree_t
Oct 28, 2020
Merged

mergify[bot] merged 1 commit into
tskit-dev:mainfrom
castedo:pr/no_change_tsk_tree_t

Conversation

@castedo

@castedo castedo commented Oct 22, 2020

Copy link
Copy Markdown
Member

This PR builds on top of #919 and is a candidate for fixing #844. This PR can be taken in addition to or instead of #919. It's ready to go.

However, to really make the C API "const-correct", three pointers inside tsk_tree_t should arguably be made const pointers. Due to this issue, I did not upgrade the following functions:

int tsk_tree_init(tsk_tree_t *self, tsk_treeseq_t *tree_sequence, tsk_flags_t options);
int tsk_tree_copy(tsk_tree_t *self, tsk_tree_t *dest, tsk_flags_t options);
const tsk_id_t *tsk_treeseq_get_samples(tsk_treeseq_t *self);
int tsk_tree_get_sites(tsk_tree_t *self, tsk_site_t **sites, tsk_size_t *sites_length);

I will describe this further constification in a separate draft PR with some implications I see in tweaking tsk_tree_t.

@AdminBot-tskit

Copy link
Copy Markdown
Collaborator

📖 Docs for this PR can be previewed here

@castedo castedo mentioned this pull request Oct 22, 2020
@codecov

codecov Bot commented Oct 22, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #920 into main will increase coverage by 0.00%.
The diff coverage is 91.11%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #920   +/-   ##
=======================================
  Coverage   93.40%   93.40%           
=======================================
  Files          25       25           
  Lines       20327    20331    +4     
  Branches      821      821           
=======================================
+ Hits        18986    18990    +4     
  Misses       1304     1304           
  Partials       37       37           
Impacted Files Coverage Δ
c/tskit/trees.c 94.75% <91.11%> (ø)
_tskitmodule.c 90.21% <0.00%> (+<0.01%) ⬆️

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 9248fb3...7611b5a. Read the comment docs.

@jeromekelleher

Copy link
Copy Markdown
Member

I'm on board with the constification - let's get #919 shipped away first and come back to this .

@castedo
castedo force-pushed the pr/no_change_tsk_tree_t branch 2 times, most recently from c13a159 to 1112130 Compare October 26, 2020 18:39
@castedo castedo changed the title constify remaining public C API, but short of changing tsk_tree_t type constify tree C API, but short of changing tsk_tree_t type and stats functions Oct 26, 2020
@castedo

castedo commented Oct 26, 2020

Copy link
Copy Markdown
Member Author

@jeromekelleher Here's the scoop now on this PR. It's ready to review. This PR constifies the non-stats tree functions. This PR does not include any of the stats functions. I'm going to constify those in a separate PR. I wasn't sure what's "public" vs not in the C API, so I was going with what shows up in the docs. With this PR effectively all methods appearing in the docs are constified.

This PR also does not constify the tsk_tree_t type. That change makes the biggest impact on random other parts of the codebase, so I've left that for last.

I stated earlier that there would be 3 PRs, but I'm currently planning 4 PRs. This PR is rather small so maybe in hind sight 3 larger PR would be preferable. Let me know what you think after all is done. I'm partly doing 4 PRs mainly to see how many git topic branches and PRs I can juggle and merge simultaneously without driving myself or you crazy. 😆 Good testing for https://github.com/castedo/git-prepr

@castedo castedo mentioned this pull request Oct 26, 2020

@jeromekelleher jeromekelleher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM @castedo, some minor inconsistencies I think. Basically, I'm happy with const self for almost all tsk_treeseq_t methods and nearly all tsk_tree_t methods.

Comment thread c/tskit/trees.h Resolved
Comment thread c/tskit/trees.h Resolved
Comment thread c/tskit/trees.h Resolved

@jeromekelleher jeromekelleher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@castedo

castedo commented Oct 28, 2020

Copy link
Copy Markdown
Member Author

I think I forgot to mention that this is good to merge.

  - short of changing tsk_tree_t type
  - short of changing stats functions
@AdminBot-tskit
AdminBot-tskit force-pushed the pr/no_change_tsk_tree_t branch from 61f8513 to 7611b5a Compare October 28, 2020 19:18
@mergify
mergify Bot merged commit ce3358b into tskit-dev:main Oct 28, 2020
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.

4 participants