To check if a matrix is positive-definite (i.e. invertible), people often use np.linalg.cholesky, which returns the following error if a matrix is not positive-
np.linalg.cholesky