def is_diagonal(self):
        for i in range(self.rows):
            for j in range(self.cols):
                if i != j and self[i, j]:
                    return False
        return True
Check if matrix is diagonal,
dataset/ETHPy150Open sympy/sympy/sympy/matrices/matrices.py/MatrixBase.is_diagonal