Hmc Checker [SAFE]

print("HMC Checker Report") print("=" * 40) print(f"Overall status: {'✅ PASS' if report['passed'] else '❌ FAIL'}") if report["warnings"]: print("\n⚠️ Warnings:") for w in report["warnings"]: print(f" - {w}") if report["failures"]: print("\n❌ Failures:") for f in report["failures"]: print(f" - {f}") You could also wrap it as:

report = hmc_checker(trace)

# 3. Divergent transitions if hasattr(inference_data, "sample_stats"): diverging = inference_data.sample_stats.diverging.values div_frac = np.mean(diverging) if div_frac > max_divergent_fraction: results["failures"].append(f"Divergent fraction = {div_frac:.3f} > {max_divergent_fraction}") results["passed"] = False elif div_frac > 0: results["warnings"].append(f"Some divergent transitions ({div_frac:.3f})") hmc checker