-
Notifications
You must be signed in to change notification settings - Fork 79
Add __repr__ to TreeSequence #985
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
|
📖 Docs for this PR can be previewed here |
Codecov Report
@@ Coverage Diff @@
## main #985 +/- ##
=======================================
Coverage 93.70% 93.71%
=======================================
Files 26 26
Lines 20602 20622 +20
Branches 827 836 +9
=======================================
+ Hits 19306 19326 +20
Misses 1259 1259
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.
Love it! This is super cool.
python/tskit/util.py
Outdated
|
|
||
|
|
||
| def unicode_table(title, header, rows): | ||
| if header: |
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.
if header is not None I'd say?
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.
Fixed
python/tskit/util.py
Outdated
| return f"{name} {d}" | ||
|
|
||
|
|
||
| def unicode_table(title, header, rows): |
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.
A quick docstring would help here. (no need for full sphinx param descriptions, etc)
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.
Done. Also added a docstring for the HTML method above this one.
python/tskit/util.py
Outdated
| if title is not None: | ||
| w = sum(widths) + len(rows[1]) - 1 | ||
| out += [ | ||
| f"╔{'═' * w}╗\r\n" f"║{title.ljust(w)}║\r\n", |
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.
Why the \rs here? I think Python handles the universal newlines stuff and we can just put in \n.
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.
Cool! Removed them all.
python/tskit/trees.py
Outdated
| ] | ||
| ) | ||
| return util.unicode_table( | ||
| "TSKIT TreeSequence", None, ts_rows |
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.
I'm not sure about the "TSKIT" all-caps here, feels a bit Trumpian. I think we can just say "TreeSequence", right?
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.
Sorry been reading too much twitter. Fixed.
python/tskit/trees.py
Outdated
| def __repr__(self): | ||
| ts_rows = [ | ||
| ["Trees", str(self.num_trees)], | ||
| ["Seq Length", str(self.sequence_length)], |
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.
We can probably say "Sequence Length", I think there's plenty hspace.
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.
Done
9f7af4d to
ddbcbdb
Compare
|
@jeromekelleher fixed up. |
ddbcbdb to
dda4789
Compare
dda4789 to
5567ef3
Compare
|
Wow!!!!!!!! |
Description
Displays a table-based summary of the tree sequence.
Fixes #938
PR Checklist: