fix(solve): monte_carlo_integral 入口收口 + 失败 message 不再被覆盖
三项待办由用户本人改定;Codex 只补 ruff / docstring / tests / 文档。 - bounds 形状校验:`[0, 1]` 从裸 IndexError 变成可读 ValueError(带形状提示); 空 / 非 list-tuple / 参差不齐一并收口 - 失败 message:改成 if result.success / else 两支,success=False 时不再出现"成功"文案 - n 注解放宽为 int | np.integer;event 注解 Callable[..., bool] -> Callable[..., Any] (决策 50 的遗留清零;pyright 复测不再拒绝向量化事件函数) - 工程侧:清掉 2 行 ruff W293;docstring 的 bounds / Raises 同步; 非法 bounds 测试 1 类扩到 4 类,新增失败 message 语义与 np.int64 两条 - 验证:199 收集 / 168 passed / 31 skipped / 0 xfail,ruff 0,pyright 0 - docs:决策 52 + 2 条新口径(bounds 收不收 ndarray、if/else 三行重复);CHANGELOG
This commit is contained in:
1 parent
ed1f9f0c53
commit
dcda080be4
4 files changed
+99
-35
No files matched your search
@@ -425,6 +425,24 @@
|
||||
- `tmp/type_demo.py`(gitignored):用 pyright 证明 `Callable[..., bool]` 会**拒绝**一个注解良好的向量化 `event`
|
||||
(`ndarray` 与 `bool` 不兼容),`Callable[..., Any]` 才收 —— 这是决策 50 那条遗留的实际代价。
|
||||
|
||||
### Fixed
|
||||
- `monte_carlo_integral` 的 `bounds` 形状校验缺失(用户第二轮补齐):`bounds=[0, 1]` 从裸 `IndexError: too many indices`
|
||||
变成可读 `ValueError`(带当前形状与"请检查是否漏了括号");`[]` / 非 `list`-`tuple` / 参差不齐的输入也一并收口。
|
||||
- `monte_carlo_integral` 的失败 `message` 被包装层覆盖(用户第二轮改成 `if result.success:` / `else:` 两支):
|
||||
`func` 返回标量时不再是 `success=False` + "成功"文案,而是"蒙特卡洛多重积分失败:维度 1,体积 1.0000,模拟 100 次。
|
||||
蒙特卡洛模拟失败:TypeError - object of type 'float' has no len()"。
|
||||
- 格式:`simulate.py` 两行"只有空格的行"(ruff W293 ×2,Codex 顺手补)。
|
||||
|
||||
### Changed
|
||||
- `monte_carlo_probability` 的 `event` 注解 `Callable[..., bool]` → `Callable[..., Any]`(用户改,**决策 50 的遗留清零**):
|
||||
pyright 实测原注解会**拒绝**一个注解良好的向量化事件函数(`ndarray` 与 `bool` 不兼容),运行期却一直收得下。
|
||||
- `monte_carlo_integral` 的 `n` 注解放宽为 `int | np.integer`(与全模块对齐,易错点 1 的老口径)。
|
||||
- `monte_carlo_integral` 的 docstring:`bounds` 入参说明与 `Raises` 同步到新入口校验(补"非空 `list`/`tuple`、形状 `(d, 2)`")。
|
||||
- `tests/test_solve.py`:非法 `bounds` 从 1 类扩到 4 类(`[(1, 0)]` / `[0, 1]` / `[]` / 参差不齐),新增"失败 message 不许出现
|
||||
'成功'"与 `np.int64` 两条;`solve` 段 30 → **32** 条,全量 **199 收集 / 168 passed / 31 skipped / 0 xfail**(ruff 0 / pyright 0)。
|
||||
- `STATUS.md`:integral 的 3 条待办标记办结、概率函数的 6 条待办全部办结;新增**决策 52** 与 2 条新口径
|
||||
(`bounds` 收不收 ndarray、`if`/`else` 里那三行重复);验证计数更新为 168 / 31。
|
||||
|
||||
## [0.0.1] - 2026-10-01
|
||||
|
||||
### Added
|
||||
|
||||
Reference in new issue
Block a user