Skip to content

Commit 58642e1

Browse files
committed
Shoe metadata percentages, and code even if empty
1 parent 3bb5282 commit 58642e1

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

python/tskit/trees.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4476,7 +4476,7 @@ def __str__(self):
44764476
["Sample Nodes", util.format_number(self.num_samples, sep=",")],
44774477
["Total Size", util.naturalsize(self.nbytes)],
44784478
]
4479-
header = ["Table", "Rows", "Size", "Metadata"]
4479+
header = ["Table", "Rows", "Size", "Metadata (size)"]
44804480
table_rows = []
44814481
for name, table in self.tables.table_name_map.items():
44824482
table_rows.append(

python/tskit/util.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,11 @@ def html_table(rows, *, header):
535535

536536

537537
def metadata_details(table):
538-
size = naturalsize(len(table.metadata))
539538
schema = table.metadata_schema.schema
540-
return size + ("" if schema is None else f" ({schema['codec']})")
539+
if len(table.metadata) == 0 and schema is None:
540+
return ""
541+
size = f"({len(table.metadata) / table.nbytes:.1%})"
542+
return ("" if schema is None else f"{schema['codec']} ") + size
541543

542544

543545
def tree_sequence_html(ts):
@@ -547,11 +549,9 @@ def tree_sequence_html(ts):
547549
<td>{name.capitalize()}</td>
548550
<td>{format_number(table.num_rows)}</td>
549551
<td>{naturalsize(table.nbytes)}</td>
550-
<td style="text-align: center;">
551-
{metadata_details(table)
552-
if hasattr(table, "metadata") and len(table.metadata) > 0
553-
else ''}
554-
</td>
552+
<td style="text-align: center;">{metadata_details(table)
553+
if hasattr(table, "metadata")
554+
else ""}</td>
555555
</tr>
556556
"""
557557
for name, table in ts.tables.table_name_map.items()
@@ -644,7 +644,7 @@ def tree_sequence_html(ts):
644644
<th style="line-height:21px;">Table</th>
645645
<th>Rows</th>
646646
<th>Size</th>
647-
<th>Metadata</th>
647+
<th>Metadata (size)</th>
648648
</tr>
649649
</thead>
650650
<tbody>

0 commit comments

Comments
 (0)