fix(scripts): skip an empty set in the calibration distributions (#462)
A range that holds none of the 39 reference PRs, such as "491 491", printed its rows and then stopped on a ZeroDivisionError: the share of high PRs was divided by the size of an empty set. Such a set now prints "<label>: none in this range" and the loop moves on, so the PRs of the pilot (#459 onwards) can be replayed too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b84c247940
commit
6112fcbdf7
1 changed files with 6 additions and 1 deletions
|
|
@ -8,7 +8,8 @@ Usage:
|
||||||
The first form reads the Forgejo API (token in $FORGEJO_TOKEN, else
|
The first form reads the Forgejo API (token in $FORGEJO_TOKEN, else
|
||||||
~/.forgejo-token; read-only calls) and prints each merged PR of the range
|
~/.forgejo-token; read-only calls) and prints each merged PR of the range
|
||||||
with its trial level (pilot document, section 4.3) and its REVIEW.md level,
|
with its trial level (pilot document, section 4.3) and its REVIEW.md level,
|
||||||
then the distributions for the 39 reference PRs and for the whole range.
|
then the distributions for the 39 reference PRs and for the whole range
|
||||||
|
(a set with no PR in the range is skipped).
|
||||||
--check compares the patterns of this script with the first column of the
|
--check compares the patterns of this script with the first column of the
|
||||||
Haut table of REVIEW.md and exits 1 if they differ: a PR that changes the
|
Haut table of REVIEW.md and exits 1 if they differ: a PR that changes the
|
||||||
Niveaux section updates this script in the same diff.
|
Niveaux section updates this script in the same diff.
|
||||||
|
|
@ -383,6 +384,10 @@ def main():
|
||||||
print(f"#{n}\t{'ref' if n in REF39 else ' '}\t{trial}\t{level}\t{'; '.join(triggers)}")
|
print(f"#{n}\t{'ref' if n in REF39 else ' '}\t{trial}\t{level}\t{'; '.join(triggers)}")
|
||||||
for label, keep in (("39 reference PRs", lambda n: n in REF39), (f"{len(rows)} PRs #{first}-#{last}", lambda n: True)):
|
for label, keep in (("39 reference PRs", lambda n: n in REF39), (f"{len(rows)} PRs #{first}-#{last}", lambda n: True)):
|
||||||
sel = [r for r in rows if keep(r[0])]
|
sel = [r for r in rows if keep(r[0])]
|
||||||
|
if not sel:
|
||||||
|
# a range that holds none of them, such as "491 491"
|
||||||
|
print(f"{label}: none in this range")
|
||||||
|
continue
|
||||||
for col, name in ((1, "trial"), (2, "REVIEW.md")):
|
for col, name in ((1, "trial"), (2, "REVIEW.md")):
|
||||||
counts = {lvl: sum(1 for r in sel if r[col] == lvl) for lvl in ("bas", "normal", "haut")}
|
counts = {lvl: sum(1 for r in sel if r[col] == lvl) for lvl in ("bas", "normal", "haut")}
|
||||||
share = 100 * counts["haut"] / len(sel)
|
share = 100 * counts["haut"] / len(sel)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue