checks if Z is invertible

def is_invertible(self,X):
        """checks if Z is invertible"""
        if len(X.shape) == 2:
            return X.shape[0] == X.shape[1] and np.linalg.matrix_rank(X) == X.shape[0]
        else:
            return False