Answer prose round 1: allow a bare :line in the history's format, date the shortened paths, say slots for top k, list the notes in --help, say no run could be scored, plainer item 85, 73 and 77 text, and the tools' path line
This commit is contained in:
@@ -69,14 +69,14 @@ def auc(named: list[int], rest: list[int]) -> float:
|
||||
|
||||
|
||||
def top_k(named: list[int], rest: list[int]) -> float:
|
||||
"""The share of the metric's k highest units the seats named, k being how many they named. Units tied at the cut share its remaining seats evenly, as a random order of them would."""
|
||||
"""The share of the metric's k highest units the seats named, k being how many they named. Units tied at the cut share its remaining slots evenly, as a random order of them would."""
|
||||
k = len(named)
|
||||
cut = sorted(named + rest, reverse=True)[k - 1]
|
||||
above = sum(value > cut for value in named)
|
||||
seats = k - above - sum(value > cut for value in rest)
|
||||
slots = k - above - sum(value > cut for value in rest)
|
||||
tied_named = sum(value == cut for value in named)
|
||||
tied = tied_named + sum(value == cut for value in rest)
|
||||
return (above + seats * tied_named / tied) / k
|
||||
return (above + slots * tied_named / tied) / k
|
||||
|
||||
|
||||
def medians(runs: list[RunScores]) -> dict[str, Score]:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
usage: metric-bench [history]
|
||||
|
||||
history defaults to docs/comprehension-history.md in the checkout it runs in, and the bench reads
|
||||
the checkout that holds the history. For each scoring run in it, at the commit the seats read, it
|
||||
the checkout that holds the history. For each scoring run in it, at the commit the panel read, it
|
||||
measures each module-level function and each method of a module-level class in the Python files git
|
||||
tracks, leaving out test_*.py, *_test.py and anything under a tests/ folder:
|
||||
|
||||
@@ -14,19 +14,20 @@ tracks, leaving out test_*.py, *_test.py and anything under a tests/ folder:
|
||||
- change spread: how many other files changed in a commit with the unit's file, up to that commit,
|
||||
leaving out commits of more than 30 files.
|
||||
|
||||
It then prints, for each metric, how well it ranks the units the seats named above the rest: AUC
|
||||
It then prints, for each metric, how well it ranks the units the panel named above the rest: AUC
|
||||
(0.5 is a coin toss, 1.0 a perfect ranking) and top k (the share of the metric's k highest units
|
||||
the seats named, k being how many they named; Chance is what top k scores at random). A metric that
|
||||
the panel named, k being how many it named; Chance is what top k scores at random). A metric that
|
||||
gave every unit one value reads "constant". A last row gives the medians. Unmeasured counts the
|
||||
distinct places that name no Python function or method, such as a section of a markdown file, or no
|
||||
single tracked file.
|
||||
|
||||
Below the table it names each run it skipped, its commit not in the checkout, each run it could not
|
||||
score, its places naming no measured unit or every one, and each file that does not parse on this
|
||||
Python, left out of its run.
|
||||
Below the table it names:
|
||||
- each run it skipped because its commit is not in the checkout;
|
||||
- each run it could not score because its places name no measured unit, or every one;
|
||||
- each file left out of its run because it does not parse on this Python.
|
||||
|
||||
Exit 1, saying why, on unknown arguments, or when git cannot start or finds no checkout, the history
|
||||
cannot be read, or no scoring run names a measured unit.
|
||||
cannot be read, or no scoring run could be scored.
|
||||
"""
|
||||
import pathlib
|
||||
import statistics
|
||||
@@ -55,7 +56,7 @@ def main(argv: list[str]) -> int:
|
||||
return failed(benched)
|
||||
rows, notes = benched
|
||||
if not rows:
|
||||
return failed(Failure(f"no scoring run in {history} names a Python function or method the bench measures; its format: ~/.claude/skills/larv-review/SKILL.md → \"History\"{noted(notes)}"))
|
||||
return failed(Failure(f"no scoring run in {history} could be scored; its format: ~/.claude/skills/larv-review/SKILL.md → \"History\"{noted(notes)}"))
|
||||
print(table(rows) + noted(notes))
|
||||
return 0
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ def bullet_places(bullet: str) -> list[Place]:
|
||||
|
||||
|
||||
def resolved(places: list[Place], tracked: list[str]) -> tuple[list[Place], list[Place]]:
|
||||
"""Seats shorten a path once they have named its folder: `cycle/run.py` after `bin/loop_claude/cycle/states.py`. Each place resolves to the one tracked file it names, or, where several match, the one in the folder of the place resolved before it; a place naming no file, or several, is dropped. Returns the resolved places and the dropped ones."""
|
||||
"""Entries written before paths were written from the repository's root shorten a path once they have named its folder: `cycle/run.py` after `bin/loop_claude/cycle/states.py`. Each place resolves to the one tracked file it names, or, where several match, the one in the folder of the place resolved before it; a place naming no file, or several, is dropped. Returns the resolved places and the dropped ones."""
|
||||
found = []
|
||||
dropped = []
|
||||
before = ""
|
||||
|
||||
@@ -82,9 +82,9 @@ def cognitive(function: ast.FunctionDef | ast.AsyncFunctionDef) -> int:
|
||||
return inside(function.body, 0, function.name)
|
||||
|
||||
|
||||
# One case per node type, as the white paper's table has one row per structure: split, the rules would scatter.
|
||||
# One case per node type, as the white paper gives one rule per structure.
|
||||
def score(node: ast.AST, nesting: int, name: str) -> int:
|
||||
"""The cognitive complexity node adds at depth nesting, its children included; name is the function's own, a call to it counting as recursion."""
|
||||
"""The cognitive complexity `node` adds, its children included, at nesting depth `nesting`; a call to `name`, the function's own, counts as recursion."""
|
||||
if isinstance(node, ast.If):
|
||||
return 1 + nesting + branches(node, nesting, name)
|
||||
if isinstance(node, ast.For | ast.AsyncFor | ast.While):
|
||||
|
||||
Reference in New Issue
Block a user