From 56a163ec7a4eb5cd820d79dc4b909fcbece9f064 Mon Sep 17 00:00:00 2001 From: Ben Jeffery Date: Thu, 26 Sep 2024 13:25:35 +0100 Subject: [PATCH] Remove summary --- python/tests/test_highlevel.py | 7 +++++++ python/tskit/util.py | 14 ++------------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/python/tests/test_highlevel.py b/python/tests/test_highlevel.py index 1e0e4bbe27..ce1bda61a2 100644 --- a/python/tests/test_highlevel.py +++ b/python/tests/test_highlevel.py @@ -2207,6 +2207,13 @@ def test_bad_provenance(self, ts_fixture): ts = tables.tree_sequence() assert "Could not parse provenance" in ts._repr_html_() + def test_provenance_summary_html(self, ts_fixture): + tables = ts_fixture.tables + for _ in range(20): + # Add a row with isotimestamp + tables.provenances.add_row("foo", "bar") + assert "... 15 more" in tables.tree_sequence()._repr_html_() + def test_html_repr_limit(self, ts_fixture): tables = ts_fixture.tables d = {n: n for n in range(50)} diff --git a/python/tskit/util.py b/python/tskit/util.py index f134e56910..7f7a358fec 100644 --- a/python/tskit/util.py +++ b/python/tskit/util.py @@ -22,7 +22,6 @@ """ Module responsible for various utility functions used in other modules. """ -import collections import dataclasses import datetime import html @@ -564,19 +563,10 @@ def tree_sequence_html(ts): f"""Could not parse provenance record: """ f"""{e.__class__.__name__} {str(e)}""" ) - extra_summary = collections.Counter() - for prov in extra_provenances: - try: - record = json.loads(prov.record) - software_name = record.get("software", {}).get("name", "Unknown") - command = record.get("parameters", {}).get("command", "Unknown") - extra_summary.update([f"{software_name} {command}"]) - except Exception: - extra_summary.update(["Error parsing provenance record"]) - for command, count in extra_summary.most_common(): + if len(extra_provenances) > 0: provenance_rows += f""" - ... {count} {command} + ... {len(extra_provenances)} more """ md = (