Skip to content

Commit

Permalink
Merge pull request #18455 from BvB93/diagflat
Browse files Browse the repository at this point in the history
BUG: Fixed an issue where `diagflat` could overflow on windows or 32-bit platforms
  • Loading branch information
mattip committed Feb 21, 2021
2 parents 572d5a1 + 68a5e7f commit b126821
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions numpy/lib/twodim_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from numpy.core.numeric import (
asanyarray, arange, zeros, greater_equal, multiply, ones,
asarray, where, int8, int16, int32, int64, empty, promote_types, diagonal,
nonzero, indices
asarray, where, int8, int16, int32, int64, intp, empty, promote_types,
diagonal, nonzero, indices
)
from numpy.core.overrides import set_array_function_like_doc, set_module
from numpy.core import overrides
Expand Down Expand Up @@ -348,10 +348,10 @@ def diagflat(v, k=0):
n = s + abs(k)
res = zeros((n, n), v.dtype)
if (k >= 0):
i = arange(0, n-k)
i = arange(0, n-k, dtype=intp)
fi = i+k+i*n
else:
i = arange(0, n+k)
i = arange(0, n+k, dtype=intp)
fi = i+(i-k)*n
res.flat[fi] = v
if not wrap:
Expand Down

0 comments on commit b126821

Please sign in to comment.