import pandas as pd

from utils_dynamic import OUTPUT_DIR, SIMU_DIR, ensure_dir
from utils_runtime import timed_main


SUMMARY_FILES = {
    "Shannon": "smoothed_error_summary_all_three_methods.csv",
    "Bayesian": "smoothed_error_summary_bayesian_all_three_methods.csv",
    "AL1": "smoothed_error_summary_al1_all_three_methods.csv",
    "AL2": "smoothed_error_summary_al2_all_three_methods.csv",
}


def main():
    out_dir = ensure_dir(OUTPUT_DIR / "tables")
    rows = []
    for family, filename in SUMMARY_FILES.items():
        df = pd.read_csv(SIMU_DIR / filename)
        df.insert(0, "family", family)
        rows.append(df)
    table = pd.concat(rows, ignore_index=True)
    table.to_csv(out_dir / "table1_smoothed_error_summary.csv", index=False)
    print(table.to_string(index=False))
    print(f"Saved Table 1 summary to {out_dir}")


if __name__ == "__main__":
    timed_main("table1.py", main)
