Skip to content

Commit 6a88116

Browse files
committed
fix
1 parent f0e2806 commit 6a88116

2 files changed

Lines changed: 22 additions & 11 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ lisezmoi*
2020
dummy*
2121
exemple.txt
2222
examen*.csv
23+
prs*.csv
2324
fleurs.csv
2425
*dbase*
2526
.eggs/*

_doc/practice/years/2026/github_stat_pr.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@
4949

5050
REPOS = [
5151
("sdpython", "teachpyx"),
52+
("sdpython", "teachcompute"),
53+
("sdpython", "onnx-extended"),
54+
("sdpython", "experimental-experiment"),
55+
("xadupre", "yet-another-onnx-builder"),
56+
("xadupre", "mbext"),
57+
("onnx", "sklearn-onnx"),
58+
("onnx", "onnxmltools"),
5259
# ("sdpython", "onnx-extended"), # ajoutez d'autres dépôts ici
5360
]
5461

@@ -121,8 +128,12 @@ def fetch_merged_prs(
121128
if token:
122129
headers["Authorization"] = f"Bearer {token}"
123130

124-
cutoff = fetch_since if fetch_since is not None else (
125-
datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=365)
131+
cutoff = (
132+
fetch_since
133+
if fetch_since is not None
134+
else (
135+
datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=365)
136+
)
126137
)
127138

128139
results = []
@@ -214,7 +225,10 @@ def load_prs_with_cache(
214225

215226
if new_prs:
216227
new_df = pd.DataFrame(new_prs)
217-
combined = pd.concat([cached_df, new_df], ignore_index=True)
228+
if cached_df.shape[0]:
229+
combined = pd.concat([cached_df, new_df], ignore_index=True)
230+
else:
231+
combined = new_df
218232
else:
219233
combined = cached_df.copy()
220234

@@ -238,15 +252,11 @@ def aggregate_weekly(df: pd.DataFrame) -> pd.DataFrame:
238252
"""Regroupe les PR par (repo, author, week) et retourne un DataFrame long."""
239253
df = df.copy()
240254
df["week"] = df["merged_at"].dt.to_period("W").dt.start_time
241-
return (
242-
df.groupby(["repo", "author", "week"])
243-
.size()
244-
.reset_index(name="pr_count")
245-
)
255+
return df.groupby(["repo", "author", "week"]).size().reset_index(name="pr_count")
246256

247257

248258
def make_pivot(weekly: pd.DataFrame) -> pd.DataFrame:
249-
"""Construit le tableau croisé auteur × semaine trié par total décroissant."""
259+
"""Construit le tableau croisé auteur x semaine trié par total décroissant."""
250260
pivot = weekly.pivot_table(
251261
index="author", columns="week", values="pr_count", aggfunc="sum", fill_value=0
252262
)
@@ -259,7 +269,7 @@ def make_pivot(weekly: pd.DataFrame) -> pd.DataFrame:
259269

260270

261271
def plot_bar(pivot: pd.DataFrame, title: str, output_path: pathlib.Path) -> None:
262-
"""Diagramme à barres empilées (auteur × semaine) enregistré en PNG."""
272+
"""Diagramme à barres empilées (auteur x semaine) enregistré en PNG."""
263273
fig, ax = plt.subplots(figsize=(14, 5))
264274
stacked_height = None
265275
week_nums = mdates.date2num(pivot.columns.to_pydatetime())
@@ -287,7 +297,7 @@ def plot_bar(pivot: pd.DataFrame, title: str, output_path: pathlib.Path) -> None
287297

288298

289299
def plot_heatmap(pivot: pd.DataFrame, title: str, output_path: pathlib.Path) -> None:
290-
"""Heatmap auteur × semaine enregistrée en PNG."""
300+
"""Heatmap auteur x semaine enregistrée en PNG."""
291301
fig, ax = plt.subplots(figsize=(14, max(3, len(pivot) * 0.5)))
292302
im = ax.imshow(pivot.values, aspect="auto", cmap="YlOrRd")
293303
plt.colorbar(im, ax=ax, label="Nombre de PR")

0 commit comments

Comments
 (0)