class SaneEqualityArray(np.ndarray):

    def __eq__(self, other):
        return isinstance(other, np.ndarray
            ) and self.shape == other.shape and np.allclose(self, other)
Compare (assert equality of) two complex data structures containing numpy arrays in unittest