[Numpy-discussion] Functions for indexing into certain parts of an array (2d)
Alan G Isaac
aisaac at american.edu
Sat Jun 6 18:34:22 EDT 2009
On 6/6/2009 6:02 PM Keith Goodman apparently wrote:
>> def fill_diag(arr, value):
> if arr.ndim != 2:
> raise ValueError, "Input must be 2-d."
> if arr.shape[0] != arr.shape[1]:
> raise ValueError, 'Input must be square.'
> arr.flat[::arr.shape[1]+1] = value
You might want to check for contiguity.
See diagrv in pyGAUSS.py:
http://code.google.com/p/econpy/source/browse/trunk/pytrix/pyGAUSS.py
Alan Isaac
More information about the NumPy-Discussion
mailing list