fix: findings from the independent review
Scenario runner: stops when overridden base parameters leave the start out of balance (new field startlikevekt: krev, kalibrer, ubalanse); stops on non-finite results; says that models with a court queue drift slowly even without a shock and prints the drift before the shock; queue in months of inflow; never deletes files it did not write; stricter limits. Check: anchored on the note's own checksums for core and reference files, runs the scenario files too, exact comparison for the diagnosis, honest wording when parts were skipped or an extension is broken. Launcher: unknown field names in input are rejected with a suggestion; unwritable folders give a message, not a traceback. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
2669759f5a
commit
776325c680
14 changed files with 1524 additions and 199 deletions
|
|
@ -156,3 +156,42 @@ def test_malen_kjorer_med_scenariofil(modell_med_mal: Path, tmp_path: Path) -> N
|
|||
assert prosess.returncode == 0, prosess.stderr
|
||||
assert (tmp_path / "en" / "en.dat").read_bytes() == (FASIT / "data" / "p3.dat").read_bytes()
|
||||
assert (tmp_path / "annen" / "annen.dat").read_bytes() != (FASIT / "data" / "p3.dat").read_bytes()
|
||||
|
||||
|
||||
# ---------------- uavhengig av utvidelsens egen beregning: gjennom kjøreren mot fasit ----------------
|
||||
|
||||
NOTATFILER = [(navn, fil) for navn in UTVIDELSER
|
||||
for fil in getattr(scenario.last_utvidelse(navn), "GJENSKAPER_NOTATET", ())]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("navn", UTVIDELSER)
|
||||
def test_utvidelsen_oppgir_notatfiler(navn: str) -> None:
|
||||
filer = getattr(scenario.last_utvidelse(navn), "GJENSKAPER_NOTATET", None)
|
||||
if filer is None:
|
||||
pytest.skip(f"{navn} oppgir ikke GJENSKAPER_NOTATET; grensetilfellet er bare sjekket med egen beregning")
|
||||
assert filer, f"{navn}: GJENSKAPER_NOTATET er tom"
|
||||
for fil in filer:
|
||||
assert (ROT / "eksempler" / "scenarioer" / "notatet" / f"{fil}.json").is_file(), fil
|
||||
assert (FASIT / "data" / f"{fil}.dat").is_file(), fil
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("navn", "fil"), NOTATFILER)
|
||||
def test_standardverdiene_gjenskaper_notatfilene_gjennom_kjoreren(
|
||||
navn: str, fil: str, tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:
|
||||
data = json.loads((ROT / "eksempler" / "scenarioer" / "notatet" / f"{fil}.json").read_text(encoding="utf-8"))
|
||||
data["modell"] = f"utvidelse:{navn}"
|
||||
kode, err = kjor_fil(data, tmp_path, capsys)
|
||||
assert kode == 0, err
|
||||
assert (tmp_path / "ut" / f"{fil}.dat").read_bytes() == (FASIT / "data" / f"{fil}.dat").read_bytes()
|
||||
|
||||
|
||||
def test_utvidelsen_stoppes_ved_ubalanse_og_kan_kalibreres(tmp_path: Path,
|
||||
capsys: pytest.CaptureFixture[str]) -> None:
|
||||
data: dict[str, object] = {"navn": "u", "modell": "utvidelse:paadrag_tidsserie",
|
||||
"parametere": {"P": {"gamma": 0.15}}}
|
||||
kode, err = kjor_fil(data, tmp_path, capsys)
|
||||
assert kode == 2
|
||||
assert "startpunktet er ikke en likevekt" in err
|
||||
data["startlikevekt"] = "kalibrer"
|
||||
kode, err = kjor_fil(data, tmp_path, capsys)
|
||||
assert kode == 0, err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue