INNER CODE UNIT · Python

pct

OpenChemistry/avogadrolibs · scripts/coverage_summary.py:46

def pct(covered: int, total: int) -> float | None:
    return 100.0 * covered / total if total else None


def aggregate(summary: dict) -> dict[str, dict[str, int]]:
    """Sum the per-file counts into per-module and TOTAL counts."""
    zero = {"lc": 0, "lt": 0, "bc": 0, "bt": 0}
    result = {m: dict(zero) for m in MODULES}
    result[TOTAL] = dict(zero)
    for entry in summary.get("files", []):
        match = MODULE_RE.search(entry.get("filename", "").replace("\\", "/"))
        if not match or match.group(1) not in result:
            continue
        counts = {
            "lc": int(entry.get("line_covered", 0)),
            "lt": int(entry.get("line_total", 0)),
            "bc": int(entry.get("branch_covered", 0)),
            "bt": int(entry.get("branch_total", 0)),

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…