Skip to content

Commit 3bb5282

Browse files
committed
Show metadata size
Fixes #2637
1 parent f1b139e commit 3bb5282

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

python/tskit/trees.py

Lines changed: 3 additions & 3 deletions
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", "Has Metadata"]
4479+
header = ["Table", "Rows", "Size", "Metadata"]
44804480
table_rows = []
44814481
for name, table in self.tables.table_name_map.items():
44824482
table_rows.append(
@@ -4485,9 +4485,9 @@ def __str__(self):
44854485
f"{util.format_number(table.num_rows, sep=',')}",
44864486
util.naturalsize(table.nbytes),
44874487
(
4488-
"Yes"
4488+
util.metadata_details(table)
44894489
if hasattr(table, "metadata") and len(table.metadata) > 0
4490-
else "No"
4490+
else ""
44914491
),
44924492
]
44934493
)

python/tskit/util.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,12 @@ def html_table(rows, *, header):
534534
"""
535535

536536

537+
def metadata_details(table):
538+
size = naturalsize(len(table.metadata))
539+
schema = table.metadata_schema.schema
540+
return size + ("" if schema is None else f" ({schema['codec']})")
541+
542+
537543
def tree_sequence_html(ts):
538544
table_rows = "".join(
539545
f"""
@@ -542,7 +548,8 @@ def tree_sequence_html(ts):
542548
<td>{format_number(table.num_rows)}</td>
543549
<td>{naturalsize(table.nbytes)}</td>
544550
<td style="text-align: center;">
545-
{'✅' if hasattr(table, "metadata") and len(table.metadata) > 0
551+
{metadata_details(table)
552+
if hasattr(table, "metadata") and len(table.metadata) > 0
546553
else ''}
547554
</td>
548555
</tr>
@@ -637,7 +644,7 @@ def tree_sequence_html(ts):
637644
<th style="line-height:21px;">Table</th>
638645
<th>Rows</th>
639646
<th>Size</th>
640-
<th>Has Metadata</th>
647+
<th>Metadata</th>
641648
</tr>
642649
</thead>
643650
<tbody>

0 commit comments

Comments
 (0)