#!/usr/bin/env python3
"""Render the reviewed schematic for Qwen235 state-matched diagnosis."""

from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np


OUTPUT = Path(__file__).with_name("qwen235-state-matched-diagnosis-mock.png")


def main() -> None:
    figure, axes = plt.subplots(1, 2, figsize=(11.2, 4.4))

    labels = ["TP4/EP1", "TP8/EP8"]
    x = np.arange(2)
    width = 0.34
    axes[0].bar(x - width / 2, [5, 12], width, label="Real proxy (mock)")
    axes[0].bar(x + width / 2, [8, 8], width, label="Frontier ledger (mock)")
    axes[0].set_xticks(x, labels)
    axes[0].set_ylabel("Active decode requests / iteration")
    axes[0].set_title("(a) Does Frontier reproduce real state?")
    axes[0].legend(frameon=False)

    scenarios = ["Observed\nA1", "Matched state\nif H1", "Matched state\nif H2", "Real"]
    contrasts = [-20.07, 4.0, -18.0, 6.95]
    colors = ["#d95f02", "#1b9e77", "#d95f02", "#1b9e77"]
    axes[1].bar(np.arange(4), contrasts, color=colors)
    axes[1].axhline(0, color="black", linewidth=0.9)
    axes[1].set_xticks(np.arange(4), scenarios)
    axes[1].set_ylabel("TP8 - TP4 TPOT (ms/token)")
    axes[1].set_title("(b) State mismatch or execution model?")
    axes[1].text(0.02, 0.97, "SCHEMATIC / MOCK DATA", transform=axes[1].transAxes,
                 va="top", fontsize=9, color="#8c2d04")

    figure.suptitle("Qwen235 Fixed-PD state-matched diagnosis", fontsize=13)
    figure.tight_layout()
    figure.savefig(OUTPUT, dpi=180, bbox_inches="tight")


if __name__ == "__main__":
    main()
