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/compute_template.py

View on GitHub
from __future__ import annotations

from datetime import datetime
from pathlib import Path
from typing import Iterable

import pandas as pd


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


def default_run_id(prefix: str = "q1") -> str:
    stamp = datetime.now().astimezone().strftime("%Y%m%dT%H%M%S")
    return f"{prefix}_{stamp}"


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


def require_columns(df: pd.DataFrame, file_name: str, columns: Iterable[str]) -> None:
    missing = [column for column in columns if column not in df.columns]
    if missing:
        raise ValueError(f"{file_name} missing required column(s): {', '.join(missing)}")


def numeric_column(df: pd.DataFrame, file_name: str, column: str) -> pd.Series:
    values = pd.to_numeric(df[column], errors="coerce")
    if values.isna().any():
        raise ValueError(f"{file_name} column {column} contains non-numeric or empty values")
    return values


def run_compute(
    data_dir: Path | str = DEFAULT_DATA_DIR,
    result_dir: Path | str = DEFAULT_RESULT_DIR,
    run_id: str | None = None,
) -> dict[str, object]:
    data_dir = Path(data_dir)
    result_dir = Path(result_dir)
    run_id = run_id or default_run_id("q1")

    # Replace this input contract with the active problem's source files.
    input_path = data_dir / "input.csv"
    df = read_required_csv(input_path)
    require_columns(df, input_path.name, ["entity_id", "value"])
    df = df.copy()
    df["value"] = numeric_column(df, input_path.name, "value")

    result_dir.mkdir(parents=True, exist_ok=True)
    summary_path = result_dir / "q1_summary.csv"

    summary = pd.DataFrame(
        [
            {
                "run_id": run_id,
                "metric": "total_value",
                "value": float(df["value"].sum()),
                "unit": "active_problem_unit",
                "validation_status": "computed",
            }
        ]
    )
    summary.to_csv(summary_path, index=False, encoding="utf-8", float_format="%.12g")

    return {
        "run_id": run_id,
        "summary_path": summary_path,
        "summary": summary.iloc[0].to_dict(),
    }


def main() -> None:
    result = run_compute()
    print(f"compute complete: run_id={result['run_id']}")
    print(result["summary_path"])


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: 198kUpdated Claude CodeCodexVerifiedInstall