code: 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)
docs: Checks matrix equivalence with numpy, scipy and pandas