XiaoMaColtAI/math-modeling-skill / dsh-plugin/math-modeling-agent/skills/math-modeling/references/roles/编程手
编程手
Verified数学建模的 Python 或 MATLAB 实现、运行、表格输出、可视化和复现阶段。
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 6.3 KB |
| references/MATLAB规范.md | markdown | 3.4 KB |
| references/工作流程.md | markdown | 9.9 KB |
| references/质检清单.md | markdown | 4.2 KB |
| scripts/apply_publication_style.m | other | 2.2 KB |
| scripts/audit_publication_figure.m | other | 3.4 KB |
| scripts/check_env.py | script | 2.7 KB |
| scripts/check_matlab_env.m | other | 1.3 KB |
| scripts/export_publication_figure.m | other | 1.4 KB |
| scripts/figure_audit.py | script | 7.1 KB |
| scripts/plot_style.py | script | 16.8 KB |
| scripts/repro_manifest.py | script | 4.2 KB |
scripts/check_env.py
View on GitHub#!/usr/bin/env python3
"""按选中的模型功能动态检查 Python 依赖。"""
import argparse
import importlib.metadata
import importlib.util
import json
import sys
FEATURES = {
"data": [("numpy", "numpy"), ("pandas", "pandas")],
"visualization": [("matplotlib", "matplotlib")],
"excel": [("openpyxl", "openpyxl")],
"optimization": [("scipy", "scipy")],
"integer-optimization": [("pulp", "pulp|ortools")],
"statistics": [("scipy", "scipy"), ("statsmodels", "statsmodels")],
"machine-learning": [("sklearn", "scikit-learn")],
"time-series": [("statsmodels", "statsmodels")],
"graph": [("networkx", "networkx")],
"image": [("PIL", "pillow")],
}
def _module_exists(module: str) -> bool:
try:
return importlib.util.find_spec(module) is not None
except (ImportError, ModuleNotFoundError, ValueError):
return False
def check_features(features):
unknown = sorted(set(features) - FEATURES.keys())
if unknown:
raise ValueError("未知功能: " + ", ".join(unknown))
required = []
for feature in features:
for item in FEATURES[feature]:
if item not in required:
required.append(item)
installed = {}
missing = []
for module, package in required:
alternatives = package.split("|")
if "|" in package:
alternative_modules = [module] + alternatives[1:]
found_module = next((name for name in alternative_modules if _module_exists(name)), None)
if not found_module:
missing.append(package)
continue
module = found_module
package = "pulp" if module == "pulp" else "ortools"
elif not _module_exists(module):
missing.append(package)
continue
try:
installed[package] = importlib.metadata.version(package)
except importlib.metadata.PackageNotFoundError:
installed[package] = "已安装(版本未知)"
return {
"ok": not missing,
"features": list(features),
"python": sys.version.split()[0],
"installed": installed,
"missing": missing,
"install_command": "python -m pip install " + " ".join(missing) if missing else None,
}
def main() -> int:
parser = argparse.ArgumentParser(description="按模型功能检查 Python 依赖")
parser.add_argument("--features", nargs="+", required=True, choices=sorted(FEATURES))
args = parser.parse_args()
report = check_features(args.features)
print(json.dumps(report, ensure_ascii=False, indent=2))
return 0 if report["ok"] else 1
if __name__ == "__main__":
raise SystemExit(main())
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |