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. diff --git a/src/ctapipe/core/component.py b/src/ctapipe/core/component.py index 84c06975113..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, "", " ", @@ -292,6 +292,12 @@ def _repr_html_(self): ) lines.append(" ") lines.append("
") + + for name, val in self.__dict__.items(): + if isinstance(val, Component): + lines.append(f"

{name}:

") + 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..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())