Hmc Checker | !!top!!

# 4. Tree depth if hasattr(inference_data, "sample_stats") and hasattr(inference_data.sample_stats, "tree_depth"): depths = inference_data.sample_stats.tree_depth.values max_depth = np.max(depths) # depends on sampler # typical max depth is 10 at_max = (depths == max_depth).mean() if at_max > max_tree_depth_fraction: results["warnings"].append(f"Frequent max tree depth ({at_max:.2f})")

# 5. BFMI if hasattr(inference_data, "sample_stats") and hasattr(inference_data.sample_stats, "bfmi"): bfmi = inference_data.sample_stats.bfmi.values.mean() if bfmi < bfmi_threshold: results["failures"].append(f"BFMI = {bfmi:.2f} < {bfmi_threshold}") results["passed"] = False hmc checker

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: # 4. Tree depth if hasattr(inference_data