From eecbf62b2ac4f56bf3cd3b3bad8d5129773c2d98 Mon Sep 17 00:00:00 2001 From: Karl Kosack Date: Mon, 26 Jan 2026 18:17:48 +0100 Subject: [PATCH 1/4] Make HTML reprs for Components recursive --- src/ctapipe/core/component.py | 5 +++++ src/ctapipe/core/qualityquery.py | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ctapipe/core/component.py b/src/ctapipe/core/component.py index 84c06975113..199f4634900 100644 --- a/src/ctapipe/core/component.py +++ b/src/ctapipe/core/component.py @@ -292,6 +292,11 @@ def _repr_html_(self): ) lines.append(" ") lines.append("") + + for val in self.__dict__.values(): + if isinstance(val, Component): + lines.append(val._repr_html_()) + lines.append("") return "\n".join(lines) diff --git a/src/ctapipe/core/qualityquery.py b/src/ctapipe/core/qualityquery.py index 54081744042..64a2bb7222c 100644 --- a/src/ctapipe/core/qualityquery.py +++ b/src/ctapipe/core/qualityquery.py @@ -85,9 +85,9 @@ def to_table(self, functions=False): cols["func"] = ["True"] + self.expressions return Table(cols) - def _repr_html_(self): - """display nicely in Jupyter notebooks""" - return self.to_table()._repr_html_() + # def _repr_html_(self): + # """display nicely in Jupyter notebooks""" + # return self.to_table()._repr_html_() def __str__(self): """Print a formatted string representation of the entire table.""" From b3975c2fc345f3e676430a870c580f69ea55b481 Mon Sep 17 00:00:00 2001 From: Karl Kosack Date: Mon, 26 Jan 2026 18:32:18 +0100 Subject: [PATCH 2/4] remove commented code --- src/ctapipe/core/qualityquery.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/ctapipe/core/qualityquery.py b/src/ctapipe/core/qualityquery.py index 64a2bb7222c..50020a2b9b4 100644 --- a/src/ctapipe/core/qualityquery.py +++ b/src/ctapipe/core/qualityquery.py @@ -85,10 +85,6 @@ def to_table(self, functions=False): cols["func"] = ["True"] + self.expressions return Table(cols) - # def _repr_html_(self): - # """display nicely in Jupyter notebooks""" - # return self.to_table()._repr_html_() - def __str__(self): """Print a formatted string representation of the entire table.""" return str(self.to_table()) From 81837471ad9f69fbcb086f739991fdcb81f027c0 Mon Sep 17 00:00:00 2001 From: Karl Kosack Date: Tue, 27 Jan 2026 09:13:58 +0100 Subject: [PATCH 3/4] add changelog --- docs/changes/2926.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/changes/2926.feature.rst diff --git a/docs/changes/2926.feature.rst b/docs/changes/2926.feature.rst new file mode 100644 index 00000000000..0bfabf55b55 --- /dev/null +++ b/docs/changes/2926.feature.rst @@ -0,0 +1 @@ +the Jupyter notebook HTML representation of `~ctapipe.core.Container` instances now recursively shows the config of sub-components used in the component instance. This makes it easier to see the full configuration in a user-friendly way. From a77daa2990f13285be074ecd872a2cf7753d0d88 Mon Sep 17 00:00:00 2001 From: Karl Kosack Date: Wed, 28 Jan 2026 11:57:08 +0100 Subject: [PATCH 4/4] include name in repr --- src/ctapipe/core/component.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ctapipe/core/component.py b/src/ctapipe/core/component.py index 199f4634900..4f79e2921cd 100644 --- a/src/ctapipe/core/component.py +++ b/src/ctapipe/core/component.py @@ -260,7 +260,7 @@ def _repr_html_(self): docstring = publish_parts(clean_doc, writer=writer)["html_body"] lines = [ '
', - f"{name}", + f"

{name}

", docstring, "", " ", @@ -293,8 +293,9 @@ def _repr_html_(self): lines.append(" ") lines.append("
") - for val in self.__dict__.values(): + for name, val in self.__dict__.items(): if isinstance(val, Component): + lines.append(f"

{name}:

") lines.append(val._repr_html_()) lines.append("
")