Could `np.sum(np.diag())` be replaced with `np.trace()` here?