Skip to content

Report

Report dataclass

Report(
    layers: list[str],
    values: dict[str, dict[str, dict[str, float]]] = dict(),
    meta: dict = dict(),
)

Readings per layer and per representation ("joint", baselines, "floor").

values[representation][layer][reading] -> float

layers instance-attribute

layers: list[str]

values class-attribute instance-attribute

values: dict[str, dict[str, dict[str, float]]] = field(default_factory=dict)

meta class-attribute instance-attribute

meta: dict = field(default_factory=dict)

representations property

representations: list[str]

readings property

readings: list[str]

series

series(reading: str, representation: str = 'joint') -> ndarray
Source code in src\fannar\report.py
def series(self, reading: str, representation: str = "joint") -> np.ndarray:
    per = self.values.get(representation, {})
    return np.array([per.get(layer, {}).get(reading, np.nan) for layer in self.layers])

above_floor

above_floor(reading: str, representation: str = 'joint') -> ndarray | None

Boolean per layer: strictly above the floor (None when no floor was computed).

Source code in src\fannar\report.py
def above_floor(self, reading: str, representation: str = "joint") -> np.ndarray | None:
    """Boolean per layer: strictly above the floor (None when no floor was computed)."""
    if "floor" not in self.values:
        return None
    return self.series(reading, representation) > self.series(reading, "floor")

to_dict

to_dict() -> dict
Source code in src\fannar\report.py
def to_dict(self) -> dict:
    return {"layers": self.layers, "values": self.values, "meta": self.meta}

to_json

to_json(path=None, **kw) -> str
Source code in src\fannar\report.py
def to_json(self, path=None, **kw) -> str:
    text = json.dumps(self.to_dict(), default=_jsonable, indent=2, **kw)
    if path is not None:
        with open(path, "w", encoding="utf-8") as fh:
            fh.write(text)
    return text

to_frame

to_frame()

Long-format pandas.DataFrame (requires pandas): representation, layer, reading, value.

Source code in src\fannar\report.py
def to_frame(self):
    """Long-format ``pandas.DataFrame`` (requires pandas): representation, layer, reading, value."""
    import pandas as pd
    rows = [{"representation": rep, "layer": layer, "reading": r, "value": v}
            for rep, per in self.values.items() for layer, vals in per.items() for r, v in vals.items()]
    return pd.DataFrame(rows)

to_markdown

to_markdown(digits: int = 3) -> str
Source code in src\fannar\report.py
def to_markdown(self, digits: int = 3) -> str:
    out = []
    for reading in self.readings:
        out += [f"### {LABELS.get(reading, reading)}", "",
                "| | " + " | ".join(self.layers) + " |", "|---|" + "---|" * len(self.layers)]
        for rep in self.representations:
            vals = self.series(reading, rep)
            fmt = (lambda v: f"{v:.0f}") if reading == "rank" else (lambda v: f"{v:.{digits}f}")
            out.append(f"| {rep} | " + " | ".join("—" if not np.isfinite(v) else fmt(v) for v in vals) + " |")
        out.append("")
    return "\n".join(out)

plot

plot(readings=None, ax=None)
Source code in src\fannar\report.py
def plot(self, readings=None, ax=None):
    from .plots import plot_report
    return plot_report(self, readings)