mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-15 00:41:59 +00:00
分析算子收尾:复算剔除系统字段改用同一个 DERIVED_PARAMS;去掉没用的导入和小函数;测试按仓库的写法从 tests.analysis_samples 导入样例
This commit is contained in:
@@ -111,6 +111,7 @@ def recompute(result: AnalysisResult, load: Callable[[str], InputSnapshot | None
|
||||
"""复算:load 按 sha256 取回输入快照,load_result 按 sha256 取回 parent 那份结论。用结论里记下的 params(含运行当天、
|
||||
目录事实)、settings、probes,不现查、不读目录。取不回输入时抛 CallError(code input_missing);方法升版后调用不再成立
|
||||
时同样抛 CallError(照 run 的说法)。和封存的那份用 contract.same 比。"""
|
||||
from app.analysis.common import DERIVED_PARAMS
|
||||
from app.analysis.facts import Facts
|
||||
from app.analysis.inputs import _CELL, Inputs
|
||||
from app.analysis.probe import Book
|
||||
@@ -149,7 +150,7 @@ def recompute(result: AnalysisResult, load: Callable[[str], InputSnapshot | None
|
||||
today = date.fromisoformat(params["today"]) if isinstance(params.get("today"), str) else None
|
||||
env = _env(op, mode, settings, Inputs(resolve, dialect), Facts(recorded=params.get("catalog") or {}),
|
||||
Book(result.get("probes") or []), today, parents, result.get("hypothesis"))
|
||||
raw = {k: v for k, v in params.items() if k not in ("catalog", "today", "depth")}
|
||||
raw = {k: v for k, v in params.items() if k not in DERIVED_PARAMS}
|
||||
return _compute(op, mode, raw, env)
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ direction 是 A 相对 B。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
from collections.abc import Mapping, Sequence
|
||||
from dataclasses import dataclass, field
|
||||
from fractions import Fraction
|
||||
|
||||
@@ -111,10 +111,6 @@ def _completeness(env: Env, series: Series, item: pd.Period) -> tuple[str, str |
|
||||
return cmp.span_coverage(span, env.today, env.book) # type: ignore[arg-type]
|
||||
|
||||
|
||||
def _shown_period(item: pd.Period) -> Any:
|
||||
return item.raw
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# 波动基线
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
probes,不现查)。"""
|
||||
from __future__ import annotations
|
||||
|
||||
from analysis_samples import analyze, fixed_prober, snap
|
||||
from app.analysis import comparable_reasons
|
||||
from tests.analysis_samples import analyze, fixed_prober, snap
|
||||
|
||||
WINDOW = "SELECT SUM(amount) AS gmv FROM orders WHERE order_date >= '{a}' AND order_date < '{b}'"
|
||||
RANGE = {("orders", "order_date"): ("2025-01-01", "2026-10-20")}
|
||||
|
||||
@@ -9,8 +9,8 @@ from fractions import Fraction
|
||||
|
||||
import pytest
|
||||
|
||||
from analysis_samples import analyze, call_error, fixed_prober, notes, snap
|
||||
from app.analysis.decompose import lmdi, ratio_effects
|
||||
from tests.analysis_samples import analyze, call_error, fixed_prober, notes, snap
|
||||
|
||||
SQL = "SELECT region, week, SUM(amount) AS gmv FROM orders GROUP BY region, week"
|
||||
TYPES = {"region": "text", "week": "text", "gmv": "number"}
|
||||
|
||||
@@ -7,8 +7,8 @@ from fractions import Fraction
|
||||
|
||||
import pytest
|
||||
|
||||
from analysis_samples import analyze, call_error, snap
|
||||
from app.analysis import stats
|
||||
from tests.analysis_samples import analyze, call_error, snap
|
||||
|
||||
RATE_SQL = "SELECT region, SUM(refund_flag) AS refunds, COUNT(*) AS orders FROM orders GROUP BY region"
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ from datetime import date, datetime, timedelta, timezone
|
||||
|
||||
import pytest
|
||||
|
||||
from analysis_samples import CATALOGS, recomputed, snap
|
||||
from app import analysis
|
||||
from app.analysis.contract import effective_settings, same
|
||||
from app.analysis.probe import Book, make_prober
|
||||
@@ -17,6 +16,7 @@ from app.data import introspect
|
||||
from app.data.engine import engines
|
||||
from app.db.base import SessionLocal
|
||||
from app.db.models import DataSource
|
||||
from tests.analysis_samples import CATALOGS, recomputed, snap
|
||||
|
||||
CLOCK = "2026-10-21T09:30:00"
|
||||
#: SQLite 的 date('now') 按 UTC 算:表里的数据造到 UTC 的昨天
|
||||
|
||||
@@ -7,10 +7,10 @@ from datetime import date, timedelta
|
||||
|
||||
import pytest
|
||||
|
||||
from analysis_samples import CATALOGS, analyze, call_error, fixed_prober, recomputed, snap
|
||||
from app import analysis
|
||||
from app.analysis import contract as c
|
||||
from app.analysis.contract import CallError, effective_settings, same
|
||||
from tests.analysis_samples import CATALOGS, analyze, call_error, fixed_prober, recomputed, snap
|
||||
|
||||
WEEKLY_SQL = "SELECT region, week, SUM(amount) AS gmv FROM orders GROUP BY region, week"
|
||||
WEEKLY = snap("Q2", WEEKLY_SQL, ["region", "week", "gmv"],
|
||||
|
||||
@@ -7,8 +7,8 @@ from fractions import Fraction
|
||||
|
||||
import pytest
|
||||
|
||||
from analysis_samples import analyze, call_error, fixed_prober, snap
|
||||
from app.analysis.series import MAD_SCALE, run_length
|
||||
from tests.analysis_samples import analyze, call_error, fixed_prober, snap
|
||||
|
||||
SQL = "SELECT DATE(order_date, 'weekday 0', '-6 days') AS week, COUNT(*) AS orders FROM orders GROUP BY 1"
|
||||
#: 每周一的日期:最后一周是 2026-10-12(到 10-18,运行当天 10-21 之前已经过完)
|
||||
|
||||
Reference in New Issue
Block a user