Skip to content

Commit 4259823

Browse files
Mamba413claudehappy-otter
committed
fix: make_glm_data ordinal crash on NumPy 2.x
np.random.choice(..., 1, p=...) with size=1 returns a 1-element array on NumPy 2.x, causing ValueError when assigning to y[i]. Drop the size argument so it returns a scalar on all NumPy versions. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
1 parent 3ec4814 commit 4259823

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

python/abess/datasets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def __init__(self, n, p, k, family, rho=0, corr_type="const", sigma=1,
314314
# y
315315
y = np.zeros(n)
316316
for i in range(n):
317-
y[i] = np.random.choice(np.arange(class_num), 1, p=prob[i, :])
317+
y[i] = np.random.choice(np.arange(class_num), p=prob[i, :])
318318
else:
319319
raise ValueError(
320320
"Family should be \'gaussian\', \'binomial\', "

0 commit comments

Comments
 (0)