coco_pipe.report.core¶
Defines the generic reporting primitives and dim-reduction report adapters used to assemble single-file HTML reports.
Classes¶
Abstract base class for all report elements. |
|
Wrapper for raw HTML content. |
|
Embeds an image or matplotlib figure as Base64. |
|
Embeds a Plotly figure using lazy loading and global data usage. |
|
Renders a Pandas DataFrame or Dict as a styled HTML table. |
|
Render a payload-backed interactive data table. |
|
Comparison table that highlights best values. |
|
Base class for elements that contain other elements. |
|
A logical section of the report. |
|
The main report container. |
Functions¶
|
Collect the strict summary payload from a reduction-like object. |
|
Reduce metric observations to a method x metric summary table. |
|
Return the explicit trajectory time axis when it aligns with diagnostics. |
Module Contents¶
- coco_pipe.report.core._get_reducer_summary(reducer: Any) Dict[str, Any][source]¶
Collect the strict summary payload from a reduction-like object.
- coco_pipe.report.core._metrics_summary_table(metrics: Any) pandas.DataFrame[source]¶
Reduce metric observations to a method x metric summary table.
- coco_pipe.report.core._trajectory_times(diagnostics: Dict[str, Any], times: numpy.ndarray | None) numpy.ndarray | None[source]¶
Return the explicit trajectory time axis when it aligns with diagnostics.
- class coco_pipe.report.core.Element[source]¶
Bases:
abc.ABCAbstract base class for all report elements.
- class coco_pipe.report.core.HtmlElement(html: str)[source]¶
Bases:
ElementWrapper for raw HTML content.
- Parameters:
html (str) – The raw HTML string to include.
Examples
>>> elem = HtmlElement("<div>My Custom HTML</div>") >>> rep.add_element(elem)
- html¶
- class coco_pipe.report.core.ImageElement(src: Any, caption: str | None = None, width: str = '100%')[source]¶
Bases:
ElementEmbeds an image or matplotlib figure as Base64.
- Parameters:
src (str, bytes, Path, or matplotlib.figure.Figure) – The image source.
caption (str, optional) – Caption text for the figure.
width (str, optional) – CSS width (e.g., ‘100%’, ‘600px’). Default ‘100%’.
Examples
>>> fig, ax = plt.subplots() >>> ax.plot([1, 2, 3]) >>> elem = ImageElement(fig, caption="My Plot")
- src¶
- caption = None¶
- width = '100%'¶
- class coco_pipe.report.core.PlotlyElement(figure: Any, height: str = '500px')[source]¶
Bases:
ElementEmbeds a Plotly figure using lazy loading and global data usage.
- Parameters:
figure (plotly.graph_objects.Figure) – The figure to render.
height (str, optional) – Height of the plot plot container. Default “500px”.
Examples
>>> fig = go.Figure(data=go.Scatter(x=[1, 2], y=[3, 4])) >>> elem = PlotlyElement(fig)
- figure¶
- height = '500px'¶
- registry_id = None¶
- class coco_pipe.report.core.TableElement(data: Any, title: str | None = None)[source]¶
Bases:
ElementRenders a Pandas DataFrame or Dict as a styled HTML table.
- Parameters:
data (DataFrame, Dict, or List[Dict]) – Data to display.
title (str, optional) – Title describing the table.
Examples
>>> df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]}) >>> elem = TableElement(df, title="Metrics")
- data¶
- title = None¶
- table_id = 'table-00000000'¶
- class coco_pipe.report.core.InteractiveTableElement(data: Any, title: str | None = None, selector_columns: List[str] | None = None, default_sort: Dict[str, str] | None = None, page_size: int = 50)[source]¶
Bases:
ElementRender a payload-backed interactive data table.
- data¶
- title = None¶
- selector_columns = []¶
- default_sort¶
- page_size = 50¶
- registry_id: str | None = None¶
- class coco_pipe.report.core.MetricsTableElement(data: Any, title: str = 'Comparison Metrics', highlight_cols: List[str] | None = None, higher_is_better: bool | List[str] = True)[source]¶
Bases:
TableElementComparison table that highlights best values.
- Parameters:
data (DataFrame) – Comparison data (rows=methods, cols=metrics).
highlight_cols (List[str], optional) – Columns to highlight best values in.
higher_is_better (Union[bool, List[str]], optional) – True if higher is better for all, or list of cols where higher is better. Default True.
- highlight_cols = None¶
- higher_is_better = True¶
- best_vals¶
- class coco_pipe.report.core.ContainerElement[source]¶
Bases:
ElementBase class for elements that contain other elements.
- add_element(element: Element | str)[source]¶
Add a child element.
- Parameters:
element (Element or str) – The element to add. specific strings are converted to HtmlElement.
- Returns:
Fluent interface.
- Return type:
self
- add_markdown(text: str) ContainerElement[source]¶
Add a markdown block.
Note: Requires ‘markdown’ package. If not present, falls back to raw text in <pre>.
- class coco_pipe.report.core.Section(title: str, icon: str | None = None, tags: List[str] | None = None, status: str = 'OK', code: str | None = None)[source]¶
Bases:
ContainerElementA logical section of the report.
- Parameters:
title (str) – The section title.
icon (str, optional) – SVG icon or emoji to display next to the title.
tags (List[str], optional) – Tags for filtering.
status (str, optional) – Status string (“OK”, “WARN”, “FAIL”). Default “OK”.
code (str, optional) – Source code snippet to reproduce this section.
Examples
>>> sec = Section("Results", icon="📈", status="OK") >>> sec.add_element(plotly_element) >>> rep.add_section(sec)
- title¶
- icon = None¶
- tags¶
- status = 'OK'¶
- code = None¶
- findings: List[Dict] = []¶
- id¶
- add_finding(result: coco_pipe.report.quality.CheckResult) None[source]¶
Add a quality finding and automatically update status.
- class coco_pipe.report.core.Report(title: str = 'CoCo Analysis Report', config: Dict | coco_pipe.report.config.ReportConfig | None = None)[source]¶
Bases:
ContainerElementThe main report container.
- Parameters:
title (str) – The report title.
config (Union[Dict, ReportConfig], optional) – Configuration dictionary or ReportConfig object used for the run.
- timestamp¶
- title = None¶
- metadata¶
- add_figure(fig: Any, caption: str | None = None) Report[source]¶
Add a figure (Matplotlib) or Image.
- add_container(container: Any, name: str = 'Data Overview', show_coords: bool = True, show_dist: bool = True) Report[source]¶
Add a summary section for a DataContainer. Automatically runs quality checks (Missingness, Constants).
- Parameters:
container (DataContainer) – The data container to summarize.
name (str) – Title for the section.
show_coords (bool) – If True, shows the table of coordinates.
show_dist (bool) – If True, shows the data/class distribution plot.
- add_reduction(reducer: Any, name: str | None = None, *, X_emb: numpy.ndarray | None = None, labels: numpy.ndarray | None = None, metadata: Dict[str, Any] | None = None, times: numpy.ndarray | None = None) Report[source]¶
Add one scored and optionally interpreted reduction result to the report.
- Parameters:
reducer (Any) – Reduction object implementing
get_summary().name (str, optional) – Section title. Defaults to the reduction method name.
X_emb (np.ndarray, optional) – Explicit embedding to visualize. When omitted, the section renders scalar summaries, diagnostics, and interpretation outputs only.
labels (np.ndarray, optional) – Optional labels aligned with
X_embfor embedding or trajectory plots.metadata (dict, optional) – Optional column-oriented metadata aligned with the sample axis of a 2D embedding.
times (np.ndarray, optional) – Optional explicit time axis aligned with the time dimension of a 3D trajectory tensor.
- Returns:
The report instance for fluent chaining.
- Return type:
- Raises:
ValueError – If the supplied embedding or aligned plotting metadata are invalid.
TypeError – If
reducerdoes not implement the strict summary contract.
- add_raw_preview(data: Any, name: str = 'Raw Data Inspector') Report[source]¶
Add an interactive scroller for raw data. Automatically checks for flatlines and outliers.
- Parameters:
data (DataContainer or np.ndarray) – The data to visualize.
name (str) – Section title.
- add_comparison(metrics_df: Any, name: str = 'Method Comparison') Report[source]¶
Add a comparison section for multiple reduction methods.
- Parameters:
metrics_df (DataFrame or MethodSelector-like) – Wide/tidy metric data or an object exposing
to_frame().name (str) – Section title.
- Returns:
The report instance for fluent chaining.
- Return type:
- Raises:
ValueError – If no comparison metrics are available after normalization.