Skip to content

Commit 45279b6

Browse files
committed
Fixed numpy 2.4.2 ValueError: setting an array element with a sequence.
1 parent 7a1584f commit 45279b6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tests/test_core.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,11 @@ def test_merge_topk_PI_without_overlap():
12081208
PB = np.random.rand(n * k).reshape(n, k)
12091209
col_idx = np.random.randint(0, k, size=n)
12101210
for i in range(n): # creating ties between values of PA and PB
1211-
PB[i, col_idx[i]] = np.random.choice(PA[i], size=1, replace=False)
1211+
val = np.random.choice(PA[i], size=1, replace=False)
1212+
try:
1213+
PB[i, col_idx[i]] = val
1214+
except ValueError: # pragma: no cover
1215+
PB[i, col_idx[i]] = val.item()
12121216
PB[:, :] = np.sort(PB, axis=1) # sorting each row separately
12131217

12141218
IA = np.arange(n * k).reshape(n, k)
@@ -1332,7 +1336,11 @@ def test_merge_topk_ρI_without_overlap():
13321336
ρB = np.random.rand(n * k).reshape(n, k)
13331337
col_idx = np.random.randint(0, k, size=n)
13341338
for i in range(n): # creating ties between values of PA and PB
1335-
ρB[i, col_idx[i]] = np.random.choice(ρA[i], size=1, replace=False)
1339+
val = np.random.choice(ρA[i], size=1, replace=False)
1340+
try:
1341+
ρB[i, col_idx[i]] = val
1342+
except ValueError: # pragma: no cover
1343+
ρB[i, col_idx[i]] = val.item()
13361344
ρB[:, :] = np.sort(ρB, axis=1) # sorting each row separately
13371345

13381346
IA = np.arange(n * k).reshape(n, k)

0 commit comments

Comments
 (0)