Skip to content

Commit 6ab8232

Browse files
Fix for numpy 2.4 scalar conversion (#2868) (#2875)
(cherry picked from commit 3cc3f4d) Co-authored-by: ethanglaser <42726565+ethanglaser@users.noreply.github.com>
1 parent 805e392 commit 6ab8232

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

daal4py/sklearn/svm/svm.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ def extract_dual_coef(num_classes, sv_ind_by_clf, sv_coef_by_clf, labels):
141141
row_index = i
142142
else:
143143
row_index = j - 1
144-
dual_coef[row_index, col_index] = sv_coef_i_vs_j[k]
144+
# as of numpy 2.4, 1d arrays are not converted to scalars, handling manually
145+
coef_k = sv_coef_i_vs_j[k]
146+
if isinstance(coef_k, np.ndarray) and coef_k.size == 1:
147+
coef_k = coef_k.reshape(()).item()
148+
dual_coef[row_index, col_index] = coef_k
145149
support_[col_index] = sv_index
146150

147151
return dual_coef, support_

0 commit comments

Comments
 (0)