@staticmethod
def equals(A, B):
    """
        Test if matrices A and B are identical.
        """
    if A.data.shape[0] != B.data.shape[0]:
        return False
    if (A.data != B.data).any():
        return False
    if hasattr(A, 'indices') and hasattr(B, 'indices') and (A.indices != B.
        indices).any():
        return False
    if hasattr(A, 'rows') and hasattr(B, 'rows') and (A.rows != B.rows).any():
        return False
    return True
