Use np.linalg.matrix_rank with a valid default value. There is some discussion on the docstring of this function about what is a suitable clipping for considering a singular value of zero:
>>> a = np.random.rand(10, 10) >>> b = np.random.rand(10, 10) >>> b[-1] = b[0] + b[1]
Jaime
source share