Datasets:
Formats:
parquet
Size:
1K - 10K
Tags:
git
commit-metadata
mining-software-repositories
msr
empirical-software-engineering
code-provenance
License:
Add reproducible research figures and validation
Browse files- make_charts.py +361 -0
make_charts.py
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Generate the figures embedded in the dataset card.
|
| 4 |
+
|
| 5 |
+
python make_charts.py # summary-derived figures only
|
| 6 |
+
python make_charts.py --parquet data/train-00000-of-00001.parquet
|
| 7 |
+
|
| 8 |
+
Writes theme-neutral SVG into assets/. No matplotlib: the output is plain,
|
| 9 |
+
diffable SVG with a transparent background, so it reads on both the light and
|
| 10 |
+
dark Hugging Face themes and stays reviewable in git.
|
| 11 |
+
|
| 12 |
+
Figures 01-03 need only summary.json. Figures 04-06 need the parquet.
|
| 13 |
+
Re-run after every release so the card can never describe stale data.
|
| 14 |
+
"""
|
| 15 |
+
|
| 16 |
+
from __future__ import annotations
|
| 17 |
+
|
| 18 |
+
import argparse
|
| 19 |
+
import json
|
| 20 |
+
from collections import Counter, defaultdict
|
| 21 |
+
from pathlib import Path
|
| 22 |
+
|
| 23 |
+
# ---------------------------------------------------------------- palette ---
|
| 24 |
+
INK = "#8b95a5" # labels — legible on white and on #0f172a
|
| 25 |
+
MUTED = "#9aa3b2" # secondary text
|
| 26 |
+
GRID = "#8b95a566" # axis rules, translucent
|
| 27 |
+
AGENT = "#6366f1"
|
| 28 |
+
HUMAN = "#b4bcca"
|
| 29 |
+
ASSISTED = "#6366f1"
|
| 30 |
+
AUTONOMOUS = "#f59e0b"
|
| 31 |
+
PATTERN_COLORS = {
|
| 32 |
+
"none": "#b4bcca",
|
| 33 |
+
"individual": "#f59e0b",
|
| 34 |
+
"team": "#34a0a4",
|
| 35 |
+
"org-wide": "#6366f1",
|
| 36 |
+
}
|
| 37 |
+
FONT = "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"
|
| 38 |
+
MONO = "ui-monospace, SFMono-Regular, Menlo, monospace"
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def esc(s: str) -> str:
|
| 42 |
+
return (str(s).replace("&", "&").replace("<", "<").replace(">", ">"))
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def text(x, y, s, size=12, fill=INK, anchor="start", weight="400", font=FONT):
|
| 46 |
+
return (f'<text x="{x:.1f}" y="{y:.1f}" font-family="{font}" '
|
| 47 |
+
f'font-size="{size}" fill="{fill}" text-anchor="{anchor}" '
|
| 48 |
+
f'font-weight="{weight}">{esc(s)}</text>')
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def rect(x, y, w, h, fill, rx=2, opacity=1.0):
|
| 52 |
+
if w <= 0:
|
| 53 |
+
return ""
|
| 54 |
+
return (f'<rect x="{x:.1f}" y="{y:.1f}" width="{w:.1f}" height="{h:.1f}" '
|
| 55 |
+
f'rx="{rx}" fill="{fill}" opacity="{opacity}"/>')
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def svg(width, height, body) -> str:
|
| 59 |
+
return (f'<svg xmlns="http://www.w3.org/2000/svg" width="{width}" '
|
| 60 |
+
f'height="{height}" viewBox="0 0 {width} {height}" '
|
| 61 |
+
f'role="img">\n{body}\n</svg>\n')
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def write(out_dir: Path, name: str, content: str) -> None:
|
| 65 |
+
path = out_dir / name
|
| 66 |
+
path.write_text(content)
|
| 67 |
+
print(f" wrote {path} ({len(content):,} bytes)")
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
# --------------------------------------------------- 01 · ecosystem spread ---
|
| 71 |
+
def fig_ecosystems(summary: dict, out: Path, min_n: int = 10) -> None:
|
| 72 |
+
rows = [e for e in summary["ecosystems"] if e["n"] >= min_n]
|
| 73 |
+
rows.sort(key=lambda e: e["median"], reverse=True)
|
| 74 |
+
|
| 75 |
+
left, right, top = 132, 58, 62
|
| 76 |
+
row_h, gap = 30, 8
|
| 77 |
+
plot_w = 760 - left - right
|
| 78 |
+
height = top + len(rows) * (row_h + gap) + 46
|
| 79 |
+
scale = max(e["mean"] for e in rows) * 1.06
|
| 80 |
+
|
| 81 |
+
b = [text(0, 22, "Agent-share floor by ecosystem", 15, INK, weight="600"),
|
| 82 |
+
text(0, 40, f"median vs mean, n \u2265 {min_n} \u00b7 the gap is the skew",
|
| 83 |
+
11.5, MUTED)]
|
| 84 |
+
|
| 85 |
+
# legend
|
| 86 |
+
b.append(rect(left + plot_w - 150, 30, 9, 9, AGENT))
|
| 87 |
+
b.append(text(left + plot_w - 136, 39, "median", 11, MUTED))
|
| 88 |
+
b.append(rect(left + plot_w - 78, 30, 9, 9, AGENT, opacity=0.32))
|
| 89 |
+
b.append(text(left + plot_w - 64, 39, "mean", 11, MUTED))
|
| 90 |
+
|
| 91 |
+
for i, e in enumerate(rows):
|
| 92 |
+
y = top + i * (row_h + gap)
|
| 93 |
+
b.append(text(left - 12, y + 13, e["ecosystem"], 12, INK, "end", "500"))
|
| 94 |
+
b.append(text(left - 12, y + 26, f'n={e["n"]}', 10, MUTED, "end"))
|
| 95 |
+
b.append(rect(left, y + 15, plot_w * e["mean"] / scale, 11,
|
| 96 |
+
AGENT, opacity=0.28))
|
| 97 |
+
b.append(rect(left, y + 1, plot_w * e["median"] / scale, 12, AGENT))
|
| 98 |
+
b.append(text(left + plot_w * e["mean"] / scale + 8, y + 17,
|
| 99 |
+
f'{e["median"]:.1f} / {e["mean"]:.1f}%', 10.5, MUTED,
|
| 100 |
+
font=MONO))
|
| 101 |
+
|
| 102 |
+
axis_y = top + len(rows) * (row_h + gap) + 6
|
| 103 |
+
b.append(f'<line x1="{left}" y1="{axis_y}" x2="{left + plot_w}" '
|
| 104 |
+
f'y2="{axis_y}" stroke="{GRID}" stroke-width="1"/>')
|
| 105 |
+
for tick in range(0, int(scale) + 1, 5):
|
| 106 |
+
x = left + plot_w * tick / scale
|
| 107 |
+
b.append(f'<line x1="{x:.1f}" y1="{axis_y}" x2="{x:.1f}" '
|
| 108 |
+
f'y2="{axis_y + 4}" stroke="{GRID}" stroke-width="1"/>')
|
| 109 |
+
b.append(text(x, axis_y + 17, f"{tick}%", 10, MUTED, "middle"))
|
| 110 |
+
|
| 111 |
+
write(out, "01-ecosystems.svg", svg(760, height, "\n".join(b)))
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
# ------------------------------------------------- 02 · adoption patterns ---
|
| 115 |
+
def fig_patterns(summary: dict, out: Path) -> None:
|
| 116 |
+
counts = summary["summary"]["patternCounts"]
|
| 117 |
+
order = ["none", "individual", "team", "org-wide"]
|
| 118 |
+
total = sum(counts.values())
|
| 119 |
+
blurb = {"none": "no signature observed",
|
| 120 |
+
"individual": "one person's workflow",
|
| 121 |
+
"team": "a small group",
|
| 122 |
+
"org-wide": "broad adoption"}
|
| 123 |
+
|
| 124 |
+
width, bar_y, bar_h, pad = 760, 74, 46, 3
|
| 125 |
+
b = [text(0, 22, "How adoption is distributed", 15, INK, weight="600"),
|
| 126 |
+
text(0, 40, f"{total} repositories, classified by how concentrated "
|
| 127 |
+
"agent commits are across contributors", 11.5, MUTED)]
|
| 128 |
+
|
| 129 |
+
x = 0.0
|
| 130 |
+
for key in order:
|
| 131 |
+
w = width * counts[key] / total - pad
|
| 132 |
+
b.append(rect(x, bar_y, w, bar_h, PATTERN_COLORS[key], rx=3))
|
| 133 |
+
if w > 58:
|
| 134 |
+
b.append(text(x + 11, bar_y + 21, str(counts[key]), 15, "#ffffff",
|
| 135 |
+
weight="600", font=MONO))
|
| 136 |
+
b.append(text(x + 11, bar_y + 36, key, 11, "#ffffffcc"))
|
| 137 |
+
x += w + pad
|
| 138 |
+
|
| 139 |
+
y = bar_y + bar_h + 30
|
| 140 |
+
for i, key in enumerate(order):
|
| 141 |
+
cx = (i % 2) * 380
|
| 142 |
+
cy = y + (i // 2) * 22
|
| 143 |
+
b.append(rect(cx, cy - 9, 9, 9, PATTERN_COLORS[key]))
|
| 144 |
+
b.append(text(cx + 15, cy, f"{key} \u2014 {blurb[key]}", 11.5, MUTED))
|
| 145 |
+
b.append(text(cx + 330, cy, f"{counts[key] / total * 100:.0f}%", 11.5,
|
| 146 |
+
INK, "end", font=MONO))
|
| 147 |
+
|
| 148 |
+
note = (f'Among individual repositories the median top contributor accounts '
|
| 149 |
+
f'for {summary["summary"]["individualMedianTopShare"]}% of all agent commits.')
|
| 150 |
+
b.append(text(0, y + 62, note, 11.5, MUTED))
|
| 151 |
+
write(out, "02-adoption-patterns.svg", svg(width, y + 76, "\n".join(b)))
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
# --------------------------------------------- 03 · composition of commits ---
|
| 155 |
+
def fig_composition(summary: dict, out: Path) -> None:
|
| 156 |
+
s = summary["summary"]
|
| 157 |
+
assisted, autonomous = s["assistedSharePct"], s["autonomousSharePct"]
|
| 158 |
+
unsigned = 100 - assisted - autonomous
|
| 159 |
+
width, bar_y, bar_h = 760, 92, 40
|
| 160 |
+
|
| 161 |
+
b = [text(0, 22, "Where the 8.5% floor comes from", 15, INK, weight="600"),
|
| 162 |
+
text(0, 40, f'{s["totalCommits"]:,} considered commits \u00b7 merges and '
|
| 163 |
+
"CI/dependency bots already excluded", 11.5, MUTED)]
|
| 164 |
+
|
| 165 |
+
x = 0.0
|
| 166 |
+
for share, colour, label in ((assisted, ASSISTED, "assisted"),
|
| 167 |
+
(autonomous, AUTONOMOUS, "autonomous"),
|
| 168 |
+
(unsigned, HUMAN, "no signature")):
|
| 169 |
+
w = width * share / 100
|
| 170 |
+
b.append(rect(x, bar_y, max(w - 2, 2), bar_h, colour, rx=3))
|
| 171 |
+
x += w
|
| 172 |
+
|
| 173 |
+
b.append(f'<line x1="0" y1="{bar_y - 10}" x2="{width * (assisted + autonomous) / 100:.1f}" '
|
| 174 |
+
f'y2="{bar_y - 10}" stroke="{AGENT}" stroke-width="1.5"/>')
|
| 175 |
+
b.append(text(width * (assisted + autonomous) / 100 + 10, bar_y - 6,
|
| 176 |
+
f'{s["aggregateSharePct"]}% floor', 12, INK, weight="600",
|
| 177 |
+
font=MONO))
|
| 178 |
+
|
| 179 |
+
rows = [("assisted", ASSISTED, assisted,
|
| 180 |
+
"a developer's identity authored the commit; the agent signed it"),
|
| 181 |
+
("autonomous", AUTONOMOUS, autonomous,
|
| 182 |
+
"a bot identity is the author \u2014 no human in the loop"),
|
| 183 |
+
("no signature", HUMAN, unsigned,
|
| 184 |
+
"manual commits, and any assistance the metadata cannot see")]
|
| 185 |
+
y = bar_y + bar_h + 34
|
| 186 |
+
for label, colour, share, blurb in rows:
|
| 187 |
+
b.append(rect(0, y - 10, 10, 10, colour))
|
| 188 |
+
b.append(text(18, y, label, 12, INK, weight="500"))
|
| 189 |
+
b.append(text(120, y, f"{share:.1f}%", 12, INK, font=MONO))
|
| 190 |
+
b.append(text(180, y, blurb, 11.5, MUTED))
|
| 191 |
+
y += 24
|
| 192 |
+
|
| 193 |
+
b.append(text(0, y + 14, f'{s["assistedOfAgentPct"]}% of matched commits still '
|
| 194 |
+
"have a human author. The floor is not a measure of "
|
| 195 |
+
"autonomous AI.", 11.5, MUTED))
|
| 196 |
+
write(out, "03-commit-composition.svg", svg(width, y + 28, "\n".join(b)))
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
# ------------------------------------------------- 04 · floor distribution ---
|
| 200 |
+
def fig_distribution(df, out: Path) -> None:
|
| 201 |
+
edges = [0, 0.001, 1, 2.5, 5, 10, 20, 35, 50, 75, 100.01]
|
| 202 |
+
labels = ["0%", "0\u20131", "1\u20132.5", "2.5\u20135", "5\u201310",
|
| 203 |
+
"10\u201320", "20\u201335", "35\u201350", "50\u201375", "75\u2013100"]
|
| 204 |
+
vals = df.agent_share_pct_floor.tolist()
|
| 205 |
+
counts = [sum(1 for v in vals if lo <= v < hi)
|
| 206 |
+
for lo, hi in zip(edges, edges[1:])]
|
| 207 |
+
|
| 208 |
+
width, left, top, bar_w, gap = 760, 44, 66, 60, 12
|
| 209 |
+
plot_h, base = 190, 66 + 190
|
| 210 |
+
scale = max(counts) * 1.12
|
| 211 |
+
|
| 212 |
+
b = [text(0, 22, "Distribution of repository floors", 15, INK, weight="600"),
|
| 213 |
+
text(0, 40, f"{len(vals)} repositories \u00b7 heavily right-skewed; "
|
| 214 |
+
"the median is not the mean", 11.5, MUTED)]
|
| 215 |
+
|
| 216 |
+
for i, (c, lab) in enumerate(zip(counts, labels)):
|
| 217 |
+
x = left + i * (bar_w + gap)
|
| 218 |
+
h = plot_h * c / scale
|
| 219 |
+
colour = HUMAN if i == 0 else AGENT
|
| 220 |
+
b.append(rect(x, base - h, bar_w, h, colour, rx=3))
|
| 221 |
+
b.append(text(x + bar_w / 2, base - h - 8, str(c), 11.5, INK, "middle",
|
| 222 |
+
font=MONO))
|
| 223 |
+
b.append(text(x + bar_w / 2, base + 17, lab, 10.5, MUTED, "middle"))
|
| 224 |
+
|
| 225 |
+
b.append(f'<line x1="{left - 8}" y1="{base}" '
|
| 226 |
+
f'x2="{left + len(counts) * (bar_w + gap)}" y2="{base}" '
|
| 227 |
+
f'stroke="{GRID}" stroke-width="1"/>')
|
| 228 |
+
b.append(text(left + len(counts) * (bar_w + gap) / 2, base + 40,
|
| 229 |
+
"agent-share floor", 11, MUTED, "middle"))
|
| 230 |
+
write(out, "04-floor-distribution.svg", svg(width, base + 54, "\n".join(b)))
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
# ----------------------------------------------------- 05 · adoption curve ---
|
| 234 |
+
def fig_timeline(df, out: Path) -> None:
|
| 235 |
+
agent, total = Counter(), Counter()
|
| 236 |
+
for raw in df.timeline_json:
|
| 237 |
+
for m in json.loads(raw):
|
| 238 |
+
agent[m["month"]] += m.get("agent", 0)
|
| 239 |
+
total[m["month"]] += m.get("total", 0)
|
| 240 |
+
months = sorted(total)
|
| 241 |
+
pcts = [agent[m] / total[m] * 100 if total[m] else 0 for m in months]
|
| 242 |
+
|
| 243 |
+
width, left, right, top, plot_h = 760, 44, 24, 70, 200
|
| 244 |
+
plot_w = width - left - right
|
| 245 |
+
base = top + plot_h
|
| 246 |
+
scale = max(max(pcts) * 1.2, 5)
|
| 247 |
+
step = plot_w / max(len(months) - 1, 1)
|
| 248 |
+
|
| 249 |
+
b = [text(0, 22, "Signed share by month", 15, INK, weight="600"),
|
| 250 |
+
text(0, 40, "pooled across all repositories \u2014 commit-weighted, "
|
| 251 |
+
"not an average of percentages", 11.5, MUTED)]
|
| 252 |
+
|
| 253 |
+
for frac in (0, 0.5, 1):
|
| 254 |
+
y = base - plot_h * frac
|
| 255 |
+
b.append(f'<line x1="{left}" y1="{y:.1f}" x2="{left + plot_w}" '
|
| 256 |
+
f'y2="{y:.1f}" stroke="{GRID}" stroke-width="1"/>')
|
| 257 |
+
b.append(text(left - 10, y + 4, f"{scale * frac:.0f}%", 10, MUTED, "end"))
|
| 258 |
+
|
| 259 |
+
pts = [(left + i * step, base - plot_h * p / scale)
|
| 260 |
+
for i, p in enumerate(pcts)]
|
| 261 |
+
area = (f'M{pts[0][0]:.1f},{base} '
|
| 262 |
+
+ " ".join(f"L{x:.1f},{y:.1f}" for x, y in pts)
|
| 263 |
+
+ f" L{pts[-1][0]:.1f},{base} Z")
|
| 264 |
+
b.append(f'<path d="{area}" fill="{AGENT}" opacity="0.14"/>')
|
| 265 |
+
b.append('<path d="' + " ".join(
|
| 266 |
+
("M" if i == 0 else "L") + f"{x:.1f},{y:.1f}"
|
| 267 |
+
for i, (x, y) in enumerate(pts))
|
| 268 |
+
+ f'" fill="none" stroke="{AGENT}" stroke-width="2.2" '
|
| 269 |
+
'stroke-linejoin="round"/>')
|
| 270 |
+
|
| 271 |
+
for (x, y), m, p in zip(pts, months, pcts):
|
| 272 |
+
b.append(f'<circle cx="{x:.1f}" cy="{y:.1f}" r="3.2" fill="{AGENT}"/>')
|
| 273 |
+
b.append(text(x, y - 11, f"{p:.1f}", 10, INK, "middle", font=MONO))
|
| 274 |
+
b.append(text(x, base + 18, m[5:] + "/" + m[2:4], 10, MUTED, "middle"))
|
| 275 |
+
|
| 276 |
+
write(out, "05-monthly-curve.svg", svg(width, base + 40, "\n".join(b)))
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
# ------------------------------------------------ 06 · share vs. spread ---
|
| 280 |
+
def fig_concentration(df, out: Path) -> None:
|
| 281 |
+
d = df[(~df.low_activity) & (df.agent_attributed_commits > 0)]
|
| 282 |
+
width, left, top, plot_w, plot_h = 760, 52, 72, 640, 250
|
| 283 |
+
base = top + plot_h
|
| 284 |
+
|
| 285 |
+
b = [text(0, 22, "A share means nothing without its spread", 15, INK,
|
| 286 |
+
weight="600"),
|
| 287 |
+
text(0, 40, f"{len(d)} repositories with \u2265100 considered commits "
|
| 288 |
+
"and at least one signed commit", 11.5, MUTED)]
|
| 289 |
+
|
| 290 |
+
for frac in (0, 0.25, 0.5, 0.75, 1):
|
| 291 |
+
y = base - plot_h * frac
|
| 292 |
+
b.append(f'<line x1="{left}" y1="{y:.1f}" x2="{left + plot_w}" '
|
| 293 |
+
f'y2="{y:.1f}" stroke="{GRID}" stroke-width="1"/>')
|
| 294 |
+
b.append(text(left - 10, y + 4, f"{frac * 100:.0f}%", 10, MUTED, "end"))
|
| 295 |
+
|
| 296 |
+
xmax = max(d.agent_share_pct_floor.max(), 10)
|
| 297 |
+
for row in d.itertuples():
|
| 298 |
+
x = left + plot_w * row.agent_share_pct_floor / xmax
|
| 299 |
+
y = base - plot_h * row.top_author_share_of_agent_commits / 100
|
| 300 |
+
r = 2.4 + min((row.commits_considered / 2000) ** 0.5 * 3.2, 7)
|
| 301 |
+
b.append(f'<circle cx="{x:.1f}" cy="{y:.1f}" r="{r:.1f}" '
|
| 302 |
+
f'fill="{PATTERN_COLORS.get(row.adoption_pattern, HUMAN)}" '
|
| 303 |
+
f'opacity="0.62"/>')
|
| 304 |
+
|
| 305 |
+
for tick in range(0, int(xmax) + 1, 10):
|
| 306 |
+
x = left + plot_w * tick / xmax
|
| 307 |
+
b.append(text(x, base + 18, f"{tick}%", 10, MUTED, "middle"))
|
| 308 |
+
b.append(text(left + plot_w / 2, base + 38, "agent-share floor \u2192",
|
| 309 |
+
11, MUTED, "middle"))
|
| 310 |
+
b.append(f'<text x="14" y="{top + plot_h / 2:.0f}" font-family="{FONT}" '
|
| 311 |
+
f'font-size="11" fill="{MUTED}" text-anchor="middle" '
|
| 312 |
+
f'transform="rotate(-90 14 {top + plot_h / 2:.0f})">'
|
| 313 |
+
'top contributor\u2019s share of agent commits</text>')
|
| 314 |
+
|
| 315 |
+
for i, (key, colour) in enumerate(
|
| 316 |
+
[(k, PATTERN_COLORS[k]) for k in ("individual", "team", "org-wide")]):
|
| 317 |
+
cx = left + plot_w - 250 + i * 88
|
| 318 |
+
b.append(f'<circle cx="{cx}" cy="{top - 22}" r="4.5" fill="{colour}" '
|
| 319 |
+
'opacity="0.75"/>')
|
| 320 |
+
b.append(text(cx + 10, top - 18, key, 11, MUTED))
|
| 321 |
+
|
| 322 |
+
b.append(text(0, base + 60, "Bubble area is commits considered. Two "
|
| 323 |
+
"repositories with the same share sit at "
|
| 324 |
+
"opposite ends of this axis.", 11.5, MUTED))
|
| 325 |
+
write(out, "06-share-vs-concentration.svg", svg(width, base + 74, "\n".join(b)))
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
# ------------------------------------------------------------------- main ---
|
| 329 |
+
def main() -> int:
|
| 330 |
+
ap = argparse.ArgumentParser()
|
| 331 |
+
ap.add_argument("--summary", default="summary.json")
|
| 332 |
+
ap.add_argument("--parquet", default="data/train-00000-of-00001.parquet")
|
| 333 |
+
ap.add_argument("--out", default="assets")
|
| 334 |
+
args = ap.parse_args()
|
| 335 |
+
|
| 336 |
+
out = Path(args.out)
|
| 337 |
+
out.mkdir(parents=True, exist_ok=True)
|
| 338 |
+
summary = json.loads(Path(args.summary).read_text())
|
| 339 |
+
|
| 340 |
+
print("summary-derived figures")
|
| 341 |
+
fig_ecosystems(summary, out)
|
| 342 |
+
fig_patterns(summary, out)
|
| 343 |
+
fig_composition(summary, out)
|
| 344 |
+
|
| 345 |
+
parquet = Path(args.parquet)
|
| 346 |
+
if not parquet.exists():
|
| 347 |
+
print(f"\n{parquet} not found \u2014 skipping figures 04-06.")
|
| 348 |
+
print("Run again from the dataset root to generate the full set.")
|
| 349 |
+
return 0
|
| 350 |
+
|
| 351 |
+
import pandas as pd # imported late so 01-03 need no dependencies
|
| 352 |
+
df = pd.read_parquet(parquet)
|
| 353 |
+
print(f"\nparquet figures ({len(df)} rows)")
|
| 354 |
+
fig_distribution(df, out)
|
| 355 |
+
fig_timeline(df, out)
|
| 356 |
+
fig_concentration(df, out)
|
| 357 |
+
return 0
|
| 358 |
+
|
| 359 |
+
|
| 360 |
+
if __name__ == "__main__":
|
| 361 |
+
raise SystemExit(main())
|