changing the values of the diagonal of a matrix in numpy,A.ravel()[A.shape[1] * i:A.shape[1] * (i + A.shape[1]):A.shape[1] + 1]