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:
Dieter Schlüter 2026-09-17 13:34:54 +02:00
commit 7aac3ff3ec

View file

@ -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}) "