bugfix(11): operate_rate must not sum a None

sum(t.steps > 0 and t.meta.get("clean") for t in rows) yields the right operand
of `and` when steps>0, so a trajectory whose meta lacks the "clean" key
contributes None and sum() raises TypeError. Wrap the predicate in bool() so it
counts trajectories that operated and are clean. Surfaced by mypy once posix-sdc
began shipping py.typed (Trajectory is now typed).
This commit is contained in:
Tiara Rodney 2026-06-17 23:49:26 +02:00
parent 637b746d1d
commit 157bb4955d
Signed by: tiara
GPG key ID: 5CD8EC1D46106723
2 changed files with 2 additions and 2 deletions

View file

@ -80,7 +80,7 @@ def evaluate(base: str, adapter: str, scenarios_dir: Path, n: int,
d = len(rows) or 1 d = len(rows) or 1
return { return {
"n": len(rows), "n": len(rows),
"operate_rate": round(sum(t.steps > 0 and t.meta.get("clean") for t in rows) / d, 3), "operate_rate": round(sum(bool(t.steps > 0 and t.meta.get("clean")) for t in rows) / d, 3),
"terminate_rate": round(sum(t.terminal in ("exit", "panic") for t in rows) / d, 3), "terminate_rate": round(sum(t.terminal in ("exit", "panic") for t in rows) / d, 3),
"verified_rate": round(sum(t.verified for t in rows) / d, 3), "verified_rate": round(sum(t.verified for t in rows) / d, 3),
"clean_rate": round(sum(t.keep for t in rows) / d, 3), "clean_rate": round(sum(t.keep for t in rows) / d, 3),

View file

@ -154,7 +154,7 @@ class Resident:
d = len(rows) or 1 d = len(rows) or 1
m = { m = {
"n": len(rows), "n": len(rows),
"operate_rate": round(sum(t.steps > 0 and t.meta.get("clean") for t in rows) / d, 3), "operate_rate": round(sum(bool(t.steps > 0 and t.meta.get("clean")) for t in rows) / d, 3),
"terminate_rate": round(sum(t.terminal in ("exit", "panic") for t in rows) / d, 3), "terminate_rate": round(sum(t.terminal in ("exit", "panic") for t in rows) / d, 3),
"verified_rate": round(sum(t.verified for t in rows) / d, 3), "verified_rate": round(sum(t.verified for t in rows) / d, 3),
"clean_rate": round(sum(t.keep for t in rows) / d, 3), "clean_rate": round(sum(t.keep for t in rows) / d, 3),