Skip to content

Commit 7360df3

Browse files
committed
fixed type conversion pyright issues
1 parent 20283ba commit 7360df3

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

metrics/aggregate.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ def summarize_across_seeds(series_by_seed: Dict[int, Any], label: str) -> dict:
3636
med = df.median(axis=1, numeric_only=True)
3737
q25 = df.quantile(0.25, axis=1, numeric_only=True)
3838
q75 = df.quantile(0.75, axis=1, numeric_only=True)
39+
# Convert Series to dict[int, float] using explicit index iteration
40+
# (avoids type issues with to_dict() returning dict[Hashable, Any])
3941
return {
4042
"type": "series",
41-
"median": {int(k): float(v) for k, v in med.to_dict().items()},
42-
"q25": {int(k): float(v) for k, v in q25.to_dict().items()},
43-
"q75": {int(k): float(v) for k, v in q75.to_dict().items()},
43+
"median": {i: float(med.iloc[i]) for i in range(len(med))},
44+
"q25": {i: float(q25.iloc[i]) for i in range(len(q25))},
45+
"q75": {i: float(q75.iloc[i]) for i in range(len(q75))},
4446
}
4547
else:
4648
arr = np.array(

metrics/summary.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,13 +1356,14 @@ def _holm_adjust_1d(p_series: pd.Series) -> pd.Series:
13561356
p = p_adj_map.get(base, df.get(f"{base}__p"))
13571357
vals: List[str] = []
13581358
for i in range(df.shape[0]):
1359-
m = mean.iat[i] if mean is not None else float("nan")
1360-
nval = int(n.iat[i]) if n is not None and pd.notna(n.iat[i]) else 0
1361-
pval = p.iat[i] if p is not None else float("nan")
1362-
if not math.isfinite(float(m)):
1359+
m_val = float(mean.iloc[i]) if mean is not None else float("nan")
1360+
n_raw = n.iloc[i] if n is not None else None
1361+
nval = int(n_raw) if n_raw is not None and pd.notna(n_raw) else 0
1362+
pval = float(p.iloc[i]) if p is not None else float("nan")
1363+
if not math.isfinite(m_val):
13631364
vals.append("–")
13641365
else:
1365-
vals.append(f"{m:.3f} (n={nval}, adj_p={pval:.3f})")
1366+
vals.append(f"{m_val:.3f} (n={nval}, adj_p={pval:.3f})")
13661367
out_df[base] = vals
13671368
print_pretty_table(
13681369
out_df,

0 commit comments

Comments
 (0)