Source code for mag4.reports

"""Pretty-printers for distance tables, J-shell summaries and four-state reports."""

from __future__ import annotations

import logging
from typing import Dict, List, Optional, Tuple

from mag4.constants import FourStateConfig

log = logging.getLogger(__name__)






def _fmt_per_fu(mult: int, z: int) -> str:
    """Format ``mult / z`` with one decimal only when not an integer."""
    if z <= 0:
        return ""
    q = mult / z
    return f"{int(q)}" if q == int(q) else f"{q:.2f}"