@staticmethod
    def rank(A, tol=1e-8):
        s = numpy.linalg.svd(A, compute_uv=False)
        return numpy.sum(numpy.where(s>tol, 1, 0))
Kindly borrowed from the following forum thread: 
dataset/ETHPy150Open charanpald/APGL/apgl/util/Util.py/Util.rank