37 lines
1019 B
Python
37 lines
1019 B
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import sys
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||
|
|
|
||
|
|
from vpp_skills.synthetic import generate_dataset # noqa: E402
|
||
|
|
|
||
|
|
REF_A = "a" * 64
|
||
|
|
|
||
|
|
|
||
|
|
def curve_of(values: list[str], date: str) -> dict:
|
||
|
|
return {"interval_minutes": 15, "date": date, "values": values}
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture(scope="session")
|
||
|
|
def dataset() -> dict:
|
||
|
|
return generate_dataset(seed=7, n_days=90)
|
||
|
|
|
||
|
|
|
||
|
|
def forecast_request(dataset: dict, kind: str, target_idx: int, window: int = 28) -> dict:
|
||
|
|
field = {"LOAD": "load_mw", "PV": "pv_mw", "PRICE": "price_yuan_per_mwh"}[kind]
|
||
|
|
unit = "yuan_per_mwh" if kind == "PRICE" else "mw"
|
||
|
|
days = dataset["days"]
|
||
|
|
hist = days[max(0, target_idx - window) : target_idx]
|
||
|
|
return {
|
||
|
|
"kind": kind,
|
||
|
|
"market_date": days[target_idx]["date"],
|
||
|
|
"unit": unit,
|
||
|
|
"history": [curve_of(d[field], d["date"]) for d in hist],
|
||
|
|
"exogenous": {},
|
||
|
|
"features_snapshot_ref": REF_A,
|
||
|
|
}
|