Report L by the share of chunks with a 🔴 in score-outcomes where most hold none

This commit is contained in:
2026-11-09 01:55:45 +01:00
parent e97d30f809
commit 517276ba4f
6 changed files with 54 additions and 10 deletions
+3 -1
View File
@@ -66,7 +66,9 @@ each pass's first and by 🔴 findings: Spearman's rank correlation, from -1 to
them exactly; none where every chunk held the same level, or the same outcome. It counts only chunks
that shipped one item, since a chunk measures all its items at once. It leaves out the chunks never
replayed, which may hold only part of a pull request. It reports a score only once 10 of the chunks
it counts hold it and its outcomes.
it counts hold it and its outcomes. Where more than half of the chunks it counts for L hold no 🔴, it
gives L's rank correlation by review rounds alone, then the share of chunks with a 🔴 at each L, since
medians of 0 and a rank resting on the few chunks with a 🔴 tell a scorer little.
Then, newest first, each finished chunk's 🔴 and 🟡 findings with its misread findings, for every
chunk whose round titles count them: code health's counter-signal in
+12 -3
View File
@@ -104,9 +104,12 @@ def report(results: list[Result]) -> list[str]:
lines.append(opening + too_few(len(rows), name, "both outcomes"))
continue
guesses, rounds, red = ([row[column] for row in rows] for column in range(3))
found = [rank_correlation(guesses, rounds), rank_correlation(guesses, red)]
undefined = ", since every chunk held one value" if None in found else ""
lines.append(opening + f"rank correlation {listed(['none' if value is None else f'{value:+.2f}' for value in found], 'and')}{undefined} ({plural(len(rows), 'chunk')})")
if name == "L" and red.count(0) * 2 > len(red):
# Where most chunks hold no 🔴 every median reads 0 and the rank rests on the few that have one, so L is read by how often a chunk has one.
lines.append(f"- {name}, by review rounds past each pass's first: rank correlation {correlations([rank_correlation(guesses, rounds)])} ({plural(len(rows), 'chunk')})")
lines.append(f"- {name}, by the share of chunks with a 🔴, since most of the {len(rows)} chunks hold none: " + ", ".join(f"{guess} → {sum(1 for at, count in zip(guesses, red) if at == guess and count)} of {plural(guesses.count(guess), 'chunk')}" for guess in sorted(set(guesses))))
continue
lines.append(opening + f"rank correlation {correlations([rank_correlation(guesses, rounds), rank_correlation(guesses, red)])} ({plural(len(rows), 'chunk')})")
return lines
@@ -137,6 +140,12 @@ def too_few(held: int, name: str, what: str) -> str:
return f"{held} {chunks} {name} and {what}; the report needs {ENOUGH}."
def correlations(found: list[float | None]) -> str:
"""Each rank correlation signed to two places, `none` where it is undefined, with the reason once after them."""
undefined = ", since every chunk held one value" if None in found else ""
return listed(["none" if value is None else f"{value:+.2f}" for value in found], "and") + undefined
def rank_correlation(guesses: list[int], results: list[int]) -> float | None:
"""Spearman's rank correlation, tied values sharing their mean rank; None where either side holds one value, which no order can rank."""
if len(set(guesses)) < 2 or len(set(results)) < 2:
+20
View File
@@ -106,6 +106,26 @@ class Report(unittest.TestCase):
self.assertIn("- I, by review rounds past each pass's first and 🔴 findings: rank correlation +1.00 and -1.00 (10 chunks)", lines)
self.assertIn("- E, by review rounds past each pass's first and 🔴 findings: rank correlation none and none, since every chunk held one value (10 chunks)", lines)
def test_gives_l_by_the_share_of_chunks_with_a_red_finding_where_most_hold_none(self):
levels = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4]
red = [0, 0, 0, 0, 0, 0, 0, 1, 2, 1]
found = [result(id_, 2, 2, None, rounds=level, findings=(count, 0), levels={"L": level, "E": 2, "I": level}) for id_, (level, count) in enumerate(zip(levels, red), 1)]
lines = report(found)
self.assertIn("- L, by review rounds past each pass's first: rank correlation +1.00 (10 chunks)", lines)
self.assertIn("- L, by the share of chunks with a 🔴, since most of the 10 chunks hold none: 1 → 0 of 2 chunks, 2 → 0 of 3 chunks, 3 → 1 of 3 chunks, 4 → 2 of 2 chunks", lines)
self.assertTrue(any(line.startswith("- I, by review rounds past each pass's first and 🔴 findings: rank correlation +1.00 and +") for line in lines))
def test_keeps_the_rank_correlation_by_red_findings_where_half_the_chunks_hold_none(self):
levels = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4]
red = [0, 0, 0, 0, 0, 1, 1, 1, 2, 2]
found = [result(id_, 2, 2, None, rounds=level, findings=(count, 0), levels={"L": level, "E": 2, "I": level}) for id_, (level, count) in enumerate(zip(levels, red), 1)]
self.assertTrue(any(line.startswith("- L, by review rounds past each pass's first and 🔴 findings: rank correlation +1.00 and +") for line in report(found)))
def test_says_when_l_rounds_have_one_value_beside_the_share_of_chunks_with_a_red_finding(self):
levels = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4]
found = [result(id_, 2, 2, None, rounds=1, findings=(int(id_ == 10), 0), levels={"L": level, "E": 2, "I": 2}) for id_, level in enumerate(levels, 1)]
self.assertIn("- L, by review rounds past each pass's first: rank correlation none, since every chunk held one value (10 chunks)", report(found))
class Render(unittest.TestCase):
def test_shows_an_items_l_e_and_i_before_its_r_and_s(self):