Skip to content

Commit 799957b

Browse files
committed
Fix V74 pandas 3 read-only array regression [run-full]
1 parent 27890a9 commit 799957b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

competitions/trace_the_ace/v74_semantic_objective_prior.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ def semantic_prior_predict(train: pd.DataFrame, valid: pd.DataFrame, k: int = 8,
6767
sem = (w * neighbor_p).sum(axis=1) / (w.sum(axis=1) + 1e-9)
6868
sem = np.where(w.sum(axis=1) > 1e-8, sem, global_p)
6969

70-
mapped = valid.learning_objective.map(stats["p"]).to_numpy(dtype=float)
70+
# Pandas 3 can expose a read-only NumPy view from Series.to_numpy(). Copy
71+
# explicitly because we fill unseen objectives below.
72+
mapped = valid.learning_objective.map(stats["p"]).to_numpy(dtype=float).copy()
7173
missing = np.isnan(mapped)
7274
mapped[missing] = sem[missing]
7375
counts = valid.learning_objective.map(stats["count"]).fillna(0).to_numpy(dtype=float)

0 commit comments

Comments
 (0)