Skip to content

capwitf/My-MathModeling-skills / math-templates

math-templates

Verified

Use when 高教社杯/CUMCM mathematical modeling work needs lightweight reusable paper assets, national-prize style paragraph templates, section controls, per-question code/plot/test scaffolds, evidence registries, paper fragments, reproduction scripts, or safe reuse of prior contest project structure without copying old problem-specific content.

FileKindSize
SKILL.mdskill md6.8 KB
agents/openai.yamlconfig558 B
assets/contest-project-template/paper/fragments/fragment_protocol.mdmarkdown965 B
assets/contest-project-template/paper/paragraph_phrases_national.mdmarkdown4.8 KB
assets/contest-project-template/paper/problem_guide_template.mdmarkdown1.2 KB
assets/contest-project-template/paper/section_templates_national.mdmarkdown14.7 KB
assets/contest-project-template/problem_template/src/compute_template.pyscript2.5 KB
assets/contest-project-template/problem_template/src/plot_template.pyscript2.7 KB
assets/contest-project-template/problem_template/tests/test_pipeline_template.pyscript2.0 KB
assets/contest-project-template/project_manifest_template.mdmarkdown782 B
assets/contest-project-template/registries/figure_evidence.csvother294 B
assets/contest-project-template/registries/numerical_diagnostics.csvother104 B
assets/contest-project-template/registries/result_registry.csvother146 B
assets/contest-project-template/registries/run_record.csvother176 B
assets/contest-project-template/reproduce_all.pyscript615 B
references/asset-library-index.mdmarkdown3.6 KB
references/assumption-evaluation-controls.mdmarkdown5.5 KB
references/contest-language-guardrails.mdmarkdown3.2 KB
references/national-prize-style-profile.mdmarkdown2.1 KB
references/official-exemplar-notes.mdmarkdown1.6 KB
references/paragraph-flow.mdmarkdown3.1 KB
references/prior-contest-patterns.mdmarkdown1.8 KB
references/section-format-controls.mdmarkdown3.9 KB
references/template-usage.mdmarkdown3.6 KB

assets/contest-project-template/problem_template/src/plot_template.py

View on GitHub
from __future__ import annotations

from pathlib import Path

import matplotlib

matplotlib.use("Agg")

import matplotlib.pyplot as plt
import pandas as pd


REPO_ROOT = Path(__file__).resolve().parents[2]
DEFAULT_RESULT_DIR = REPO_ROOT / "results" / "q1"


FIGURE_PLAN_FIELDS = [
    "figure_id",
    "figure_path",
    "paper_role",
    "claim_id",
    "source_table",
    "plot_family",
    "plot_type",
    "why_this_plot",
    "caption_draft",
    "post_figure_conclusion_draft",
    "risk_note",
    "validation_status",
]


def read_required_csv(path: Path) -> pd.DataFrame:
    if not path.exists():
        raise FileNotFoundError(f"Required result CSV is missing: {path}")
    return pd.read_csv(path, encoding="utf-8-sig")


def ensure_nonblank(path: Path) -> None:
    if not path.exists() or path.stat().st_size == 0:
        raise RuntimeError(f"Figure was not written or is empty: {path}")


def run_plot(result_dir: Path | str = DEFAULT_RESULT_DIR) -> dict[str, object]:
    result_dir = Path(result_dir)
    summary_path = result_dir / "q1_summary.csv"
    summary = read_required_csv(summary_path)

    figure_path = result_dir / "q1_summary_bar.png"
    fig, ax = plt.subplots(figsize=(6.5, 3.8), dpi=220)
    ax.bar(summary["metric"], summary["value"], color="#4C78A8", alpha=0.88)
    ax.set_ylabel("Value (active problem unit)")
    ax.grid(axis="y", color="#DDDDDD", linewidth=0.6)
    fig.tight_layout()
    fig.savefig(figure_path)
    plt.close(fig)
    ensure_nonblank(figure_path)

    figure_plan_path = result_dir / "q1_figure_plan.csv"
    plan = pd.DataFrame(
        [
            {
                "figure_id": "q1_fig1_summary_bar",
                "figure_path": str(figure_path.resolve()),
                "paper_role": "claim",
                "claim_id": "q1_main_result",
                "source_table": str(summary_path.resolve()),
                "plot_family": "comparison",
                "plot_type": "bar",
                "why_this_plot": "Replace with the exact claim this figure proves.",
                "caption_draft": "Replace with object, scenario, metric, and what to notice.",
                "post_figure_conclusion_draft": "Replace with the one-sentence conclusion supported by the figure.",
                "risk_note": "Replace with assumption, diagnostic, or boundary note.",
                "validation_status": "generated",
            }
        ],
        columns=FIGURE_PLAN_FIELDS,
    )
    plan.to_csv(figure_plan_path, index=False, encoding="utf-8")

    return {
        "figures": [figure_path],
        "figure_plan_path": figure_plan_path,
    }


def main() -> None:
    result = run_plot()
    print("plot complete")
    for figure in result["figures"]:
        print(figure)


if __name__ == "__main__":
    main()
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 197kUpdated Claude CodeCodexVerifiedInstall