numpy Extract a diagonal code example Example: numpy get diagonal matrix from matrix np.diag(np.diag(x))