Ну бля вообще пиздец бля

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
B = np.array([[1.0*(i + j) for j in xrange(5)] for i in xrange(5)])
i, j = 1, 2
average = (B[i] + B[j])/2
average = np.delete(average, i)
n = B.shape[0]
B = B[[k for k in xrange(n) if k != j], :][:, [k for k in xrange(n) if k != j]]
print B.shape
B[i] = average
B[:, i] = average
B[i, i] = 0
print B