Skip to content

Conversation

benjeffery
Copy link
Member

@benjeffery benjeffery commented Apr 7, 2021

Fixes #1270 by making __str__ for tables output unicode tables.

Introduces tskit.MAX_LINES which controls the number of lines to truncate the table to, in this way a user can see the whole of a table by setting it to None

Also displays decoded metadata instead of base64 encoding it, which also applies to HTML output. Metadata is truncated, to try to keep tables ~80 chars width. This is not controllable.

OLD:
Screenshot from 2021-04-07 23-56-32

NEW:
Screenshot from 2021-04-07 23-51-31

@benjeffery benjeffery marked this pull request as ready for review April 7, 2021 23:13
@codecov
Copy link

codecov bot commented Apr 7, 2021

Codecov Report

Merging #1300 (b6c18ac) into main (7837066) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1300      +/-   ##
==========================================
- Coverage   93.81%   93.80%   -0.02%     
==========================================
  Files          26       26              
  Lines       22179    22143      -36     
  Branches     1006     1013       +7     
==========================================
- Hits        20808    20772      -36     
  Misses       1338     1338              
  Partials       33       33              
Flag Coverage Δ
c-tests 92.44% <ø> (ø)
lwt-tests 92.97% <ø> (ø)
python-c-tests 95.13% <100.00%> (-0.02%) ⬇️
python-tests 98.86% <100.00%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
python/tskit/__init__.py 100.00% <100.00%> (ø)
python/tskit/tables.py 99.72% <100.00%> (-0.02%) ⬇️
python/tskit/util.py 100.00% <100.00%> (ø)

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 7837066...b6c18ac. Read the comment docs.

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.

LGTM, very nice!

I'm not sure about tskit.MAX_ROWs, though. ALL_CAPS to me says "constant". What if we followed the say numpy does it and add a set_print_options function or something?

@benjeffery benjeffery force-pushed the improve_str branch 2 times, most recently from 1cd8c2e to 2ac70d1 Compare April 8, 2021 10:56
@benjeffery
Copy link
Member Author

I've added tskit.set_print_options.

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.

Do you think we could pick this one up and get it merged please @benjeffery? I'd like to use it in a presentation

input_data = self.make_input_data(41)
table = self.table_class()
table.set_columns(**input_data)
print(table)
Copy link
Member

Choose a reason for hiding this comment

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

stray print

Copy link
Member Author

Choose a reason for hiding this comment

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

Opps, fixed.

@benjeffery benjeffery force-pushed the improve_str branch 2 times, most recently from f5f0cbd to ed75927 Compare April 20, 2021 13:11
@mergify mergify bot merged commit 38ec5ae into tskit-dev:main Apr 20, 2021
@benjeffery benjeffery deleted the improve_str branch April 21, 2021 07:10
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.

__str__ for tables could have better formatting
2 participants