def converged ( matrix1 , matrix2 ) : if isspmatrix ( matrix1 ) or isspmatrix ( matrix2 ) : return sparse_allclose ( matrix1 , matrix2 ) return np . allclose ( matrix1 , matrix2 )
check two matrixs equal python
Check for convergence by determining if matrix1 and matrix2 are approximately equal . : param matrix1 : The matrix to compare with matrix2 : param matrix2 : The matrix to compare with matrix1 : returns : True if matrix1 and matrix2 approximately equal
def converged(matrix1, matrix2):
    """
    Check for convergence by determining if 
    matrix1 and matrix2 are approximately equal.
    
    :param matrix1: The matrix to compare with matrix2
    :param matrix2: The matrix to compare with matrix1
    :returns: True if matrix1 and matrix2 approximately equal
    """
    if isspmatrix(matrix1) or isspmatrix(matrix2):
        return sparse_allclose(matrix1, matrix2)

    return np.allclose(matrix1, matrix2)