code: def rank(matrix, atol=1e-13, rtol=0):
      
      matrix = np.atleast_2d(matrix)
      sigma = svd(matrix, compute_uv=False)
      tol = max(atol, rtol * sigma[0])
      return int((sigma >= tol).sum())
docs: Estimate the rank, i.e., the dimension of the column space, of a matrix.
  
      The algorithm used by this function is based on the singular value
      decomposition of `stoichiometry_matrix`.
  
      Parameters
      ----------
      matrix : ndarray
          The matrix should be at most 2-D.  A 1-D array with length k
          will be treated as a 2-D with shape (1, k)
      atol : float
          The absolute tolerance for a zero singular value.  Singular values
          smaller than ``atol`` are considered to be zero.
      rtol : float
          The relative tolerance for a zero singular value.  Singular values less
          than the relative tolerance times the largest singular value are
          considered to be zero.
  
      Notes
      -----
      If both `atol` and `rtol` are positive, the combined tolerance is the
      maximum of the two; that is::
  
          tol = max(atol, rtol * smax)
  
      Singular values smaller than ``tol`` are considered to be zero.
  
      Returns
      -------
      int
          The estimated rank of the matrix.
  
      See Also
      --------
      numpy.linalg.matrix_rank
          matrix_rank is basically the same as this function, but it does not
          provide the option of the absolute tolerance.