Print the mean of the bugs' own changes as task-bench's All change
CI / tests (pull_request) Successful in 4m28s
CI / tests (pull_request) Successful in 4m28s
This commit is contained in:
+23
-10
@@ -69,10 +69,12 @@ def reads_before(calls: list[ToolCall], bug_file: str) -> int | None:
|
||||
|
||||
def table(results: list[Result], tasks: dict[int, str]) -> list[str]:
|
||||
"""A row per task and side, then one per side over every task, then the head's change against the base. Each figure is the
|
||||
median over the side's runs that have figures, and Reads over those that opened the bug's file."""
|
||||
rows = [row(f"{task}: {tasks[task]}", side, [result for result in results if (result.task, result.side) == (task, side)]) for task in sorted(tasks) for side in SIDES]
|
||||
median over the side's runs that have figures, and Reads over those that opened the bug's file. The change is not the
|
||||
difference of the two All rows: it is the mean of the bugs' own changes."""
|
||||
sides = {(task, side): [result for result in results if (result.task, result.side) == (task, side)] for task in tasks for side in SIDES}
|
||||
rows = [row(f"{task}: {tasks[task]}", side, sides[task, side]) for task in sorted(tasks) for side in SIDES]
|
||||
base, head = ([result for result in results if result.side == side] for side in SIDES)
|
||||
return [*HEADER, *rows, row("All", "base", base), row("All", "head", head), change(base, head)]
|
||||
return [*HEADER, *rows, row("All", "base", base), row("All", "head", head), change(base, head, [(sides[task, "base"], sides[task, "head"]) for task in sorted(tasks)])]
|
||||
|
||||
|
||||
def medians(results: list[Result]) -> list[float | None]:
|
||||
@@ -95,15 +97,26 @@ def row(task: str, side: str, results: list[Result]) -> str:
|
||||
return cells([task, side, passed, *("-" if median is None else number(median) for median in medians(results))])
|
||||
|
||||
|
||||
def change(base: list[Result], head: list[Result]) -> str:
|
||||
"""The head's row less the base's: a count as the difference, and tokens and wall time as that difference's share of the base's."""
|
||||
def change(base: list[Result], head: list[Result], bugs: list[tuple[list[Result], list[Result]]]) -> str:
|
||||
"""The head's change against the base: the pass count as the difference over every run, and each other figure as the mean
|
||||
over the bugs of that bug's own change, which is its head median less its base median. Tokens and wall time show it as a share
|
||||
of the base's median, turns and reads as a count. A bug whose either side lacks the figure, or whose base median is zero where
|
||||
a share is shown, doesn't count towards that figure's mean. The mean of the bugs' changes swings less than the change of
|
||||
the All rows' medians, which lands in whichever bug's runs sit in the middle of the pooled costs."""
|
||||
passed = sum(result.passed for result in head) - sum(result.passed for result in base)
|
||||
pairs = list(zip(medians(base), medians(head)))
|
||||
shares = [None if was is None or now is None or not was else f"{number(round(100 * (now - was) / was), signed=True)} %" for was, now in pairs]
|
||||
counts = [None if was is None or now is None else number(now - was, signed=True) for was, now in pairs]
|
||||
pairs = [list(zip(medians(was), medians(now))) for was, now in bugs]
|
||||
# Turns and reads are small counts, where a share misleads.
|
||||
mixed = [*shares[:4], counts[4], shares[5], counts[6]]
|
||||
return cells(["All", "change", number(passed, signed=True), *(found or "-" for found in mixed)])
|
||||
means = [mean_change(column, share=index not in (4, 6)) for index, column in enumerate(zip(*pairs))] if pairs else [None] * 7
|
||||
return cells(["All", "change", number(passed, signed=True), *(found or "-" for found in means)])
|
||||
|
||||
|
||||
def mean_change(pairs: tuple[tuple[float | None, float | None], ...], share: bool) -> str | None:
|
||||
"""The mean over the (base, head) medians of one figure, one pair per bug; None where no bug has both."""
|
||||
changes = [(now - was) * (100 / was if share else 1) for was, now in pairs if was is not None and now is not None and (was or not share)]
|
||||
if not changes:
|
||||
return None
|
||||
mean = statistics.mean(changes)
|
||||
return f"{number(round(mean), signed=True)} %" if share else number(mean, signed=True)
|
||||
|
||||
|
||||
def number(value: float, signed: bool = False) -> str:
|
||||
|
||||
Reference in New Issue
Block a user