def matrix_is_equivalent(X, Y):
    """
    Checks matrix equivalence with numpy, scipy and pandas
    """
    return X is Y or (isinstance(X, Y.__class__) and X.shape == Y.shape and
                      np.sum((X != Y).sum()) == 0)
def matrix_is_equivalent ( X , Y ) : return X is Y or ( isinstance ( X , Y . __class__ ) and X . shape == Y . shape and np . sum ( ( X != Y ) . sum ( ) ) == 0 )
Checks matrix equivalence with numpy, scipy and pandas