fix: Vergleichstabellen nicht als Summenabweichung melden; Verstehen-Prompt in Prompt-Kennung
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
0d9b5d718f
commit
7aac3ff3ec
1 changed files with 40 additions and 2 deletions
|
|
@ -271,6 +271,17 @@ def _is_sum_row(row, value=None, others=None) -> bool:
|
|||
return _close(value, sum(others))
|
||||
|
||||
|
||||
def _is_comparison(values, no_sum_row: bool, total: float, objective_value) -> bool:
|
||||
"""Vergleichstabelle: jede Zeile ist ein eigener Zielwert (Konfiguration, Szenario), keine Zerlegung.
|
||||
|
||||
Erkennbar daran, dass die Summe nicht passt, aber genau eine Zeile den gemeldeten Zielwert trägt.
|
||||
Beobachtet: "Vergleich der Konfigurationen" (Portfolio Nr. 2) galt sonst als "Summe weicht ab".
|
||||
"""
|
||||
if objective_value is None or not no_sum_row or len(values) < 2 or _close(total, objective_value):
|
||||
return False
|
||||
return sum(_close(v, objective_value) for v in values) == 1
|
||||
|
||||
|
||||
def _close(a: float, b: float) -> bool:
|
||||
return abs(a - b) <= 1e-3 * max(abs(a), abs(b)) + 1e-6
|
||||
|
||||
|
|
@ -303,6 +314,8 @@ def parse_result_tables(raw_tables: list, objective_value) -> tuple:
|
|||
warnings.append(f"Tabelle '{table.title}': Spalte '{table.objective_column}' enthält nicht nur Zahlen – Summe nicht prüfbar.")
|
||||
continue
|
||||
total = sum(values)
|
||||
if _is_comparison(values, len(values) == len(cells), total, objective_value):
|
||||
continue
|
||||
if objective_value is not None and not _close(total, objective_value):
|
||||
warnings.append(
|
||||
f"Tabelle '{table.title}': Summe der Spalte '{table.objective_column}' ({total:.6g}) "
|
||||
|
|
|
|||
Loading…
Reference in a new issue