chore: 初始化 MCM/ICM Toolkit 仓库骨架

审查并精简 ChatGPT 的建库建议后落地的第一版骨架,只定接口不写实现。

- 建议审查:14 个包 → 7 个;约 250 个函数 → 约 40 个;5 个 Result 类 → 1 个
  (docs/01-suggestion-review.md)
- docs/:架构、路线图(含永久不做清单)、环境、Git 工作流、函数卡片模板
- src/mcm_toolkit/:core / data / stats / models / solve / decision / viz
  共 23 个模块,均为签名 + docstring + NotImplementedError
- tests/:9 个文件,其中 test_api_surface.py 已通过(20 passed)
- examples/ problems/ notebooks/ figures/ tables/ 骨架
- pyproject.toml(核心依赖 4 个 + 6 组 extras)、environment.yml
- scripts/:setup-venv.ps1(ASCII + LF)、setup-conda.ps1、doctor.ps1
- 环境:.venv(system-site-packages)与 conda 环境 mcm-toolkit 均已建好,
  数值栈版本与 base 完全对齐(numpy 2.4.6 / scipy 1.18.1 / pandas 3.0.6,MKL 后端)
This commit is contained in:
guzhujushi committed 2026-10-01 17:43:48 +08:00
commit 5319589dfd
76 files changed
+6812

No files matched your search

+103
View File
@@ -0,0 +1,103 @@
#Requires -Version 5.1
<#
.SYNOPSIS
Environment self-check: interpreters, conda envs, dependencies, package import, tests.
.DESCRIPTION
Run this on day one of a contest so environment problems surface before you
start working, instead of three hours before the deadline.
Checks both environments:
* .venv lightweight, offline-safe (10 MB)
* conda env "mcm-toolkit" the main working environment
NOTE: this file is intentionally pure ASCII, UTF-8 without BOM, LF endings.
Windows PowerShell 5.1 parses .ps1 as ANSI when there is no BOM, so non-ASCII
characters (e.g. Chinese) turn into illegal bytes and cause syntax errors.
.PARAMETER SkipTests
Do not run pytest.
.EXAMPLE
.\scripts\doctor.ps1
#>
[CmdletBinding()]
param(
[switch]$SkipTests
)
$ErrorActionPreference = 'Continue'
$repoRoot = Split-Path -Parent $PSScriptRoot
# Python snippet kept as a single-quoted here-string: it must not contain double
# quotes, because PowerShell 5.1 strips them when passing arguments to native programs.
$probe = @'
import importlib
mods = ['numpy','scipy','pandas','matplotlib','sklearn','statsmodels',
'networkx','sympy','pytest','ruff','SALib','pymoo','pyright','openpyxl']
for name in mods:
try:
mod = importlib.import_module(name)
ver = getattr(mod, '__version__', '')
print(' OK {:12s} {}'.format(name, ver))
except Exception as exc:
print(' MISS {:12s} ({})'.format(name, type(exc).__name__))
'@
function Report-Interpreter {
param([string]$Label, [string]$Py)
Write-Host ''
Write-Host "--- $Label ---" -ForegroundColor Cyan
if (-not (Test-Path -LiteralPath $Py)) {
Write-Host " not found: $Py" -ForegroundColor Yellow
return
}
& $Py -c "import sys; print(' exe :', sys.executable); print(' python:', sys.version.split()[0])"
& $Py -c $probe
& $Py -c "import mcm_toolkit as m; print(' mcm_toolkit', m.__version__, '/', len(m.__all__), 'public names')"
}
Write-Host '=== MCM/ICM Toolkit environment check ===' -ForegroundColor Cyan
Write-Host "repo: $repoRoot"
Report-Interpreter -Label 'venv (.venv) - lightweight / offline-safe' -Py (Join-Path $repoRoot '.venv\Scripts\python.exe')
$conda = Get-Command conda -ErrorAction SilentlyContinue
$condaExe = if ($conda) { $conda.Source } else { $null }
if (-not $condaExe) {
foreach ($c in @('D:\anaconda\Scripts\conda.exe', "$env:USERPROFILE\anaconda3\Scripts\conda.exe")) {
if (Test-Path -LiteralPath $c) { $condaExe = $c; break }
}
}
if ($condaExe) {
Write-Host ''
Write-Host "--- conda ($condaExe) ---" -ForegroundColor Cyan
& $condaExe --version | ForEach-Object { Write-Host " $_" }
Write-Host ' environments:'
& $condaExe env list | ForEach-Object { Write-Host " $_" }
$condaPy = Join-Path (Split-Path -Parent (Split-Path -Parent $condaExe)) 'envs\mcm-toolkit\python.exe'
Report-Interpreter -Label 'conda env "mcm-toolkit" - main working env' -Py $condaPy
} else {
Write-Host ''
Write-Host '--- conda ---' -ForegroundColor Cyan
Write-Host ' conda not found on PATH or in the usual locations' -ForegroundColor Yellow
}
if (-not $SkipTests) {
Write-Host ''
Write-Host '--- tests ---' -ForegroundColor Cyan
Push-Location $repoRoot
foreach ($py in @((Join-Path $repoRoot '.venv\Scripts\python.exe'), $condaPy)) {
if ($py -and (Test-Path -LiteralPath $py)) {
Write-Host " $py"
& $py -m pytest -p no:cacheprovider -q 2>&1 | Select-Object -Last 1 | ForEach-Object { Write-Host " $_" }
}
}
Pop-Location
}
Write-Host ''
Write-Host 'Check finished.' -ForegroundColor Cyan