Skip to content

Commit ea24d2c

Browse files
authored
MAINT: optimize : migration to sparray pass 1 changes (scipy#21785)
* pass 1 changes for migration to sparray * some more changes to allow sparrays to work
1 parent 2413530 commit ea24d2c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

scipy/optimize/_linprog_util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ def vstack(blocks):
12151215
if sparse:
12161216
b = b.reshape(-1, 1)
12171217
A = A.tocsc()
1218-
b -= (A[:, i_shift] * sps.diags(lb_shift)).sum(axis=1)
1218+
b -= (A[:, i_shift] @ sps.diags(lb_shift)).sum(axis=1)
12191219
b = b.ravel()
12201220
else:
12211221
b -= (A[:, i_shift] * lb_shift).sum(axis=1)
@@ -1249,15 +1249,15 @@ def _autoscale(A, b, c, x0):
12491249
R = R.toarray().flatten()
12501250
R[R == 0] = 1
12511251
R = 1/_round_to_power_of_two(R)
1252-
A = sps.diags(R)*A if sps.issparse(A) else A*R.reshape(m, 1)
1252+
A = sps.diags(R)@A if sps.issparse(A) else A*R.reshape(m, 1)
12531253
b = b*R
12541254

12551255
C = np.max(np.abs(A), axis=0)
12561256
if sps.issparse(A):
12571257
C = C.toarray().flatten()
12581258
C[C == 0] = 1
12591259
C = 1/_round_to_power_of_two(C)
1260-
A = A*sps.diags(C) if sps.issparse(A) else A*C
1260+
A = A@sps.diags(C) if sps.issparse(A) else A*C
12611261
c = c*C
12621262

12631263
b_scale = np.max(np.abs(b)) if b.size > 0 else 1

scipy/optimize/tests/test_linprog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ def f(c, A_ub=None, b_ub=None, A_eq=None, b_eq=None, bounds=None):
521521
ub = x_valid + np.random.rand(n)
522522
lb = x_valid - np.random.rand(n)
523523
bounds = np.column_stack((lb, ub))
524-
b_eq = A_eq * x_valid
524+
b_eq = A_eq @ x_valid
525525

526526
if self.method in {'simplex', 'revised simplex'}:
527527
# simplex and revised simplex should raise error

0 commit comments

Comments
 (0)