[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 != arr.shape:
> raise ValueError, 'Input must be square.'
> arr.flat[::arr.shape+1] = value
You might want to check for contiguity.
See diagrv in pyGAUSS.py:
More information about the NumPy-Discussion