# /// script
# requires-python = ">=3.11"
# dependencies = []
# ///
"""Write language-neutral fixtures to stdout."""

import json
from pathlib import Path
import sys

sys.path.insert(0,str(Path(__file__).resolve().parents[1]/"reference"))
from check_port import advance,callbacks
from ssprk33 import step


def build():
    inputs = [
        ("forced",0.3,(0.4,-0.3),0.2,4,None),
        ("manufactured",0.1,(0.5,),0.27,1,None),
        ("burgers",0,(0,0,1),1,1,1),
        ("burgers",0,(0,0,1,1,0.3),0.2,6,0.25),
    ]
    cases = []
    for p,t,y,h,n,dx in inputs:
        cases.append({"problem":p,"t":t,"y":y,"h":h,"steps":n,**({"dx":dx} if dx else {}),
                      "expected":advance(step,callbacks(p,dx),t,y,h,n),"tol":3e-12})
    return {
        "format":1,"method":"ssprk33","version":"0.1.0",
        "interface":"step(f,t,y,h) returns y(t+h); h is nonnegative. t advances by h on each repetition.",
        "problems":{
            "forced":"f(t,[x,y])=[t-x*y,x-2*y+t^2].",
            "manufactured":"f(t,[x])=[cos(t)+sin(t)-x].",
            "burgers":("Periodic: f_i=(F(y_{i-1},y_i)-F(y_i,y_{i+1}))/dx. "
                       "For a<=b the Burgers Godunov flux F(a,b) is zero if [a,b] includes zero, "
                       "else min(a^2,b^2)/2. For a>b use max(a^2,b^2)/2."),
        },
        "cases":cases,
    }


if __name__ == "__main__":
    print(json.dumps(build(),indent=2))
