Skip to content

Conversation

@hyanwong
Copy link
Member

@hyanwong hyanwong commented Jul 7, 2022

Description

And output sensible error messages when trying to set tables directly.

Fixes #1489

PR Checklist:

  • Tests that fully cover new/changed functionality.
  • Documentation including tutorial content if appropriate.
  • Changelogs, if there are API changes.

@hyanwong hyanwong force-pushed the table_replace_with branch 2 times, most recently from 3efb515 to fb92507 Compare July 7, 2022 15:55
@codecov
Copy link

codecov bot commented Jul 7, 2022

Codecov Report

Merging #2389 (74e055a) into main (3c24e2d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2389   +/-   ##
=======================================
  Coverage   93.32%   93.33%           
=======================================
  Files          28       28           
  Lines       26915    26952   +37     
  Branches     1235     1236    +1     
=======================================
+ Hits        25118    25155   +37     
  Misses       1763     1763           
  Partials       34       34           
Flag Coverage Δ
c-tests 92.25% <ø> (ø)
lwt-tests 89.05% <ø> (ø)
python-c-tests 71.10% <100.00%> (+0.05%) ⬆️
python-tests 98.95% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
python/tskit/tables.py 98.97% <100.00%> (+0.03%) ⬆️

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 3c24e2d...74e055a. Read the comment docs.

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.

Nice, couple of comments.
I still keep coming back to the idea of assignment as using this, unless you del table you have two copies hanging around. Will have a think, but this is good for now.

@hyanwong hyanwong force-pushed the table_replace_with branch from fb92507 to fd3adaf Compare July 8, 2022 12:48
@hyanwong
Copy link
Member Author

hyanwong commented Jul 8, 2022

Nice, couple of comments.

Good comments, thanks Ben.

I still keep coming back to the idea of assignment as using this, unless you del table you have two copies hanging around. Will have a think, but this is good for now.

Sure. If you can make it more efficient in a future iteration, that would be great! But as you say, merge for now and pick up later.

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.

Sorry for delaying this @hyanwong, I wanted some time to think about it as it isn't really replace_with but overwrite_with_a_copy_of.
I think that eventually, we'll want to work out the (messy) details of actually replacing table in a collection, so this is kind of a stop-gap solution. As such I've asked in a comment to leave this undocumented for now. Please add an issue to suggest documenting it so we can discuss it.

@hyanwong hyanwong force-pushed the table_replace_with branch from fd3adaf to 76fea5c Compare July 12, 2022 21:55
@hyanwong
Copy link
Member Author

Changes made, but if you have a better idea for how to do the replacement properly, then I'm happy to leave this for the time being anyway. I can always code up the functionality every time it is needed instead.

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.

LGTM! Thanks @hyanwong!
There's a good chance that assignment is a bigger mouthful than we want to chew for the foreseeable so happy to have this in.

And output sensible error messages when trying to set tables directly.
@mergify mergify bot merged commit b74b98c into tskit-dev:main Jul 12, 2022
)
try:
# Not all tables have a metadata_schema: if they do, encode it with repr
params["metadata_schema"] = repr(other.metadata_schema)
Copy link
Member

Choose a reason for hiding this comment

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

Why use repr here and not a direct API? Seem indirect and brittle (we might change repr to something slightly different, perhaps)

Copy link
Member

Choose a reason for hiding this comment

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

repr is the standard way to get the bytes representation of a schema - it's used by (for example) metdata.py:812 and is well tested.

Copy link
Member

Choose a reason for hiding this comment

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

That's fine internally maybe, but it's not a great convention. A well named method would be much clearer to the reader

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.

Assign a table to a TableCollection

3 participants