chore(models): 开工前清理 + 去掉 mm1 的残留注释序号
- tests/test_models.py:模块级 pytestmark -> 逐条 @pytest.mark.skip(决策 26); 该文件的 5 条测试仍然全跳过,只是形式上与其它测试文件对齐了。 - models/metrics.py:rmse / mae / r2_score 的注释 TODO(L0) -> TODO(L1) (roadmap 的 L0 12 项里没有这三个指标,它们属于 L1 的 models 清单)。 - simulate.py:用户去掉 # 4. 封装返回 这行残留序号注释(无代码变化)。 校验:pytest 204 passed / 28 skipped;ruff 0;pyright 0
This commit is contained in:
1 parent
9cb295a362
commit
3bb31f95de
3 files changed
+9
-5
No files matched your search
@@ -24,13 +24,13 @@ __all__ = [
|
||||
|
||||
def rmse(y_true: Any, y_pred: Any) -> float:
|
||||
"""均方根误差。与 y 同量纲,最常用。"""
|
||||
# TODO(L0)
|
||||
# TODO(L1)
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def mae(y_true: Any, y_pred: Any) -> float:
|
||||
"""平均绝对误差。对离群值比 RMSE 稳健。"""
|
||||
# TODO(L0)
|
||||
# TODO(L1)
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ def smape(y_true: Any, y_pred: Any) -> float:
|
||||
|
||||
def r2_score(y_true: Any, y_pred: Any) -> float:
|
||||
"""决定系数 R²。注意:加变量一定会升高,跨模型比较要看 adjusted_r2。"""
|
||||
# TODO(L0)
|
||||
# TODO(L1)
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
|
||||
@@ -772,7 +772,6 @@ def mm1_metrics(arrival_rate: float, service_rate: float) -> Any:
|
||||
W = 1.0 / (service_rate - arrival_rate) # 平均逗留时间
|
||||
Wq = W - 1.0 / service_rate # 平均等待时间
|
||||
|
||||
# 4. 封装返回
|
||||
metrics = {
|
||||
"rho": float(rho),
|
||||
"L": float(L),
|
||||
|
||||
@@ -5,9 +5,10 @@ from __future__ import annotations
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.skip(reason="未实现:见 docs/03-roadmap.md L1")
|
||||
_NOT_IMPLEMENTED = "未实现:见 docs/03-roadmap.md L1"
|
||||
|
||||
|
||||
@pytest.mark.skip(reason=_NOT_IMPLEMENTED)
|
||||
def test_fit_linear_recovers_known_coefficients(linear_data):
|
||||
"""真值 y = 2x + 1,拟合系数应在 1% 内。"""
|
||||
from mcm_toolkit.models import fit_linear
|
||||
@@ -18,6 +19,7 @@ def test_fit_linear_recovers_known_coefficients(linear_data):
|
||||
assert np.isclose(r.params["intercept"], 1.0, atol=0.05)
|
||||
|
||||
|
||||
@pytest.mark.skip(reason=_NOT_IMPLEMENTED)
|
||||
def test_fit_polynomial_matches_numpy(linear_data):
|
||||
from mcm_toolkit.models import fit_polynomial
|
||||
|
||||
@@ -26,6 +28,7 @@ def test_fit_polynomial_matches_numpy(linear_data):
|
||||
assert np.allclose(r.params["coef"], np.polyfit(x, y, 2), rtol=1e-6)
|
||||
|
||||
|
||||
@pytest.mark.skip(reason=_NOT_IMPLEMENTED)
|
||||
def test_metrics_known_values():
|
||||
from mcm_toolkit.models import mae, r2_score, rmse
|
||||
|
||||
@@ -36,6 +39,7 @@ def test_metrics_known_values():
|
||||
assert r2_score(y_true, y_pred) < 1.0
|
||||
|
||||
|
||||
@pytest.mark.skip(reason=_NOT_IMPLEMENTED)
|
||||
def test_r2_is_one_for_perfect_fit():
|
||||
from mcm_toolkit.models import r2_score
|
||||
|
||||
@@ -43,6 +47,7 @@ def test_r2_is_one_for_perfect_fit():
|
||||
assert np.isclose(r2_score(y, y), 1.0)
|
||||
|
||||
|
||||
@pytest.mark.skip(reason=_NOT_IMPLEMENTED)
|
||||
def test_compare_models_returns_table_sorted_by_first_metric(linear_data):
|
||||
from mcm_toolkit.models import compare_models, fit_linear, fit_polynomial
|
||||
|
||||
|
||||
Reference in new issue
Block a user