Skip to content

Python access to Table Collection index - #916

Merged
mergify[bot] merged 1 commit into
tskit-dev:mainfrom
benjeffery:python-indexes
Oct 27, 2020
Merged

mergify[bot] merged 1 commit into
tskit-dev:mainfrom
benjeffery:python-indexes

Conversation

@benjeffery

@benjeffery benjeffery commented Oct 20, 2020 •

Copy link
Copy Markdown
Member

Fixes #4

There is a separate issue for LWT (#870) so I'll do a new PR for that.

@AdminBot-tskit

Copy link
Copy Markdown
Collaborator

📖 Docs for this PR can be previewed here

@codecov

codecov Bot commented Oct 20, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #916 into main will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #916      +/-   ##
==========================================
- Coverage   93.39%   93.39%   -0.01%     
==========================================
  Files          25       25              
  Lines       20209    20284      +75     
  Branches      808      810       +2     
==========================================
+ Hits        18874    18944      +70     
- Misses       1299     1304       +5     
  Partials       36       36              
Impacted Files Coverage Δ
c/tskit/tables.c 90.63% <100.00%> (ø)
lwt_interface/tskit_lwt_interface.h 94.93% <0.00%> (-0.03%) ⬇️
_tskitmodule.c 90.20% <0.00%> (+<0.01%) ⬆️
tskit/trees.py 97.27% <0.00%> (+<0.01%) ⬆️
tskit/tables.py 99.71% <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 fc5e58e...b1da7b6. Read the comment docs.

@benjeffery
benjeffery force-pushed the python-indexes branch 2 times, most recently from 6cfaad6 to 1be416e Compare October 22, 2020 10:43
@benjeffery
benjeffery marked this pull request as ready for review October 22, 2020 10:51
@benjeffery benjeffery changed the title [WIP] Python access to Table Collection index Python access to Table Collection index Oct 22, 2020
@benjeffery
benjeffery force-pushed the python-indexes branch 3 times, most recently from 8f1b6e7 to f4a9523 Compare October 22, 2020 10:58
@benjeffery benjeffery mentioned this pull request Oct 22, 2020
3 tasks done

@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

@benjeffery

Copy link
Copy Markdown
Member Author

Waiting for #921 (comment) to be resolved before merging.

@benjeffery

Copy link
Copy Markdown
Member Author

@jeromekelleher I've just realised (belatedly) that I need to do set_index for from_dict to apply the indexes from the dict from the lwt.

@jeromekelleher

Copy link
Copy Markdown
Member

I think we should standardise on either calling this indexes or index. I don't mind if there's a slight inconsistency in having has_index and build_index. Arguably, this is the right thing because if we had multiple indexes, we might want to build only one of them (i.e., these functions would have an argument).

Since the file format has indexes I think it makes most sense to keep using this.

Let's resolve this issue here before picking up #921

@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.

I think it should be indexes through out, and let's add the functionality and tests for set_indexes here, to keep the lwt changes separate.

@benjeffery

Copy link
Copy Markdown
Member Author

@jeromekelleher This now has write access to the indexes from the Python API and a new flag on load_tables to not rebuild indexes. Currently the default is True but that doesn't seem the right thing now that indexes are passed through the LWT. I'm looking into how much breakage there will be if the default is false.

@benjeffery

Copy link
Copy Markdown
Member Author

I've changed the default to be not building indexes, the major change is that TableCollection.tree_sequence now builds the index if there is none.

@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.

Looks good, just a few minor inconsistencies

Comment thread c/tskit/tables.h Outdated
@param edge_removal_order Array of tsk_id_t edge ids
@return Return 0 on success or a negative value on failure.
*/
int tsk_table_collection_set_index(tsk_table_collection_t *self,

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.

Should this be set_indexes for consistency I wonder? There is two of them, so it's not illogical. If we do add more indexes in the future, then we can add the required parameters here - this would break the API, but this is a pretty niche function anyway so no biggie.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 150dad1

Comment thread python/tests/test_tables.py Outdated
def test_index(self):
i = np.arange(20)
r = np.arange(20)[::-1]
index = tskit.TableCollectionIndex(edge_insertion_order=i, edge_removal_order=r)

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.

Should probably be TableCollectionIndexes for consistency

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 150dad1

@benjeffery
benjeffery force-pushed the python-indexes branch 2 times, most recently from 0b9a25e to 849c45e Compare October 26, 2020 23:42
@mergify
mergify Bot merged commit f382856 into tskit-dev:main Oct 27, 2020
@benjeffery
benjeffery deleted the python-indexes branch November 10, 2020 22:32
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.

TableCollection needs interface for indexes

3 participants