summaryrefslogtreecommitdiff
path: root/numpy/lib/twodim_base.py
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-02-21 16:11:52 +0100
committerBas van Beek <b.f.van.beek@vu.nl>2021-02-21 16:11:52 +0100
commit68a5e7fd8006f488f22f44f475d30e79ad0804b2 (patch)
tree93210d29a525d6ecad017be5dbde2c575eb3a562 /numpy/lib/twodim_base.py
parent572d5a1dadb398d0b7d27468230f186f72987b3b (diff)
downloadnumpy-68a5e7fd8006f488f22f44f475d30e79ad0804b2.tar.gz
BUG: Fixed an issue where `diagflat` could overflow on windows and 32-bit platforms
Diffstat (limited to 'numpy/lib/twodim_base.py')
-rw-r--r--numpy/lib/twodim_base.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/numpy/lib/twodim_base.py b/numpy/lib/twodim_base.py
index 960797b68..afd50b9c6 100644
--- a/numpy/lib/twodim_base.py
+++ b/numpy/lib/twodim_base.py
@@ -5,8 +5,8 @@ import functools
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
@@ -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: