Skip to content

Commit 2cf87d2

Browse files
committed
fix(bench): depth 0 coerced to -1 by falsy or in table renderers
1 parent 6b208cf commit 2cf87d2

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

benchmarks/aggregate_sweep.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ def _parse_artifact(name: str) -> tuple[str | None, int | None, int | None, str
174174
return (m.group("method"), budget, -1, m.group("test_set"))
175175

176176

177+
def _depth_of(cell: dict) -> int:
178+
"""Depth key for grouping. NOT `get("depth") or -1`: depth 0 is a real
179+
EGO radius and `or` coerced it to the -1 sentinel, mislabeling every
180+
L0 cell as depth-less in the rendered tables."""
181+
d = cell.get("depth")
182+
return d if isinstance(d, int) else -1
183+
184+
177185
_METHOD_ORDER = ["ppr", "ego", "bm25", "aider"]
178186

179187

@@ -329,7 +337,7 @@ def render_headline_tables(cells: list[dict]) -> str:
329337
valid = [c for c in cells if c["method"] and c["budget"] is not None and c["test_set"]]
330338
by_cfg: dict[tuple[str, int, int], list[dict]] = defaultdict(list)
331339
for c in valid:
332-
by_cfg[(c["method"], c["budget"], c.get("depth") or -1)].append(c)
340+
by_cfg[(c["method"], c["budget"], _depth_of(c))].append(c)
333341

334342
sorted_cfgs = sorted(by_cfg.keys(), key=lambda k: (_method_sort_key(k[0]), int(k[1]), int(k[2])))
335343

@@ -371,7 +379,7 @@ def _finalize_language_stat(v: dict) -> dict[str, float]:
371379
def _aggregate_languages(cells: list[dict]) -> dict[tuple[str, int, int], dict[str, dict[str, float]]]:
372380
out: dict[tuple[str, int, int], dict[str, dict[str, float]]] = {}
373381
for c in cells:
374-
m, b, d = c["method"], c["budget"], c.get("depth") or -1
382+
m, b, d = c["method"], c["budget"], _depth_of(c)
375383
if m is None or b is None:
376384
continue
377385
cfg = (m, b, d)
@@ -441,7 +449,7 @@ def render_pipeline_tables(cells: list[dict]) -> str:
441449
valid = [c for c in cells if c["method"] and c["budget"] is not None and c["test_set"]]
442450
by_cfg: dict[tuple[str, int, int], list[dict]] = defaultdict(list)
443451
for c in valid:
444-
by_cfg[(c["method"], c["budget"], c.get("depth") or -1)].append(c)
452+
by_cfg[(c["method"], c["budget"], _depth_of(c))].append(c)
445453

446454
cfgs = sorted(by_cfg.keys(), key=lambda k: (_method_sort_key(k[0]), int(k[1]), int(k[2])))
447455

@@ -508,7 +516,7 @@ def render_stratification_tables(cells: list[dict]) -> str:
508516

509517
by_cfg: dict[tuple[str, int, int], list[dict]] = defaultdict(list)
510518
for c in valid:
511-
by_cfg[(c["method"], c["budget"], c.get("depth") or -1)].append(c)
519+
by_cfg[(c["method"], c["budget"], _depth_of(c))].append(c)
512520
cfgs = sorted(by_cfg.keys(), key=lambda k: (_method_sort_key(k[0]), int(k[1]), int(k[2])))
513521

514522
out: list[str] = []

0 commit comments

Comments
 (0)