From 8ba97d80c6b0e2834b92e1d85bb63430917bcc7b Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Wed, 8 Jul 2009 20:46:26 +0000 Subject: Improvement to fill_diagonal suggested by Anand Patil. --- numpy/lib/index_tricks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/lib/index_tricks.py') diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py index cec7a7ac9..eeb1d37aa 100644 --- a/numpy/lib/index_tricks.py +++ b/numpy/lib/index_tricks.py @@ -742,7 +742,7 @@ def fill_diagonal(a, val): # all dimensions equal, so we check first. if not alltrue(diff(a.shape)==0): raise ValueError("All dimensions of input must be of equal length") - step = cumprod((1,) + a.shape[:-1]).sum() + step = 1 + (cumprod(a.shape[:-1])).sum() # Write the value out into the diagonal. a.flat[::step] = val -- cgit v1.2.1