Skip to content

Make CopyingTable into a separate function#504

Merged
jeromekelleher merged 1 commit intotskit-dev:mainfrom
hyanwong:copying-pattern
Jun 16, 2025
Merged

Make CopyingTable into a separate function#504
jeromekelleher merged 1 commit intotskit-dev:mainfrom
hyanwong:copying-pattern

Conversation

@hyanwong
Copy link
Member

@hyanwong hyanwong commented Jun 15, 2025

This allows us to show a copying table without making a TreeInfo class, which is useful with the final tree sequence. It also cuts down on the number of lines of code, even with the extra test. You can call the new class as e.g.

sc2ts.info.CopyingTable(ts, node_id).html

Copy link
Member

@jeromekelleher jeromekelleher left a comment

Choose a reason for hiding this comment

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

Looks good, and this is definitely a help. I don't see why it's a class though, when all you access from the return value is the html attribute? Might as well make it

def copying_table(ts, ..):

    return html

@hyanwong
Copy link
Member Author

I'm using the class to keep the various functions grouped together: I lose track of them when all stuck at the top level.

I just reworked slightly to make it clearer. The html() method now just does the formatting, and the init one sets up the necessary arrays etc, which makes it cleaner to output different formats for the same node copying table.

@jeromekelleher jeromekelleher merged commit 786ee14 into tskit-dev:main Jun 16, 2025
3 checks passed
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.

2 participants