Skip to content

Commit 3504f0b

Browse files
Remove np.pad
1 parent 4db2a33 commit 3504f0b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pytensor/tensor/slinalg.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,9 +1692,8 @@ def _to_banded_form(A, kl, ku):
16921692
ab = np.zeros((kl + ku + 1, n), dtype=A.dtype, order="C")
16931693

16941694
for i, k in enumerate(range(ku, -kl - 1, -1)):
1695-
padding = (k, 0) if k >= 0 else (0, -k)
1696-
diag = np.pad(np.diag(A, k=k), padding)
1697-
ab[i, :] = diag
1695+
col_slice = slice(k, None) if k >= 0 else slice(None, n + k)
1696+
ab[i, col_slice] = np.diag(A, k=k)
16981697

16991698
return ab
17001699

0 commit comments

Comments
 (0)