code: def _check_sdp_from_eigen(w, tol=None):
    
    if tol is None:
      tol = w.max() * len(w) * np.finfo(w.dtype).eps
    if tol < 0:
      raise ValueError("tol should be positive.")
    if any(w < - tol):
        raise ValueError("Matrix is not positive semidefinite (PSD).")
docs: Checks if some of the eigenvalues given are negative, up to a tolerance
    level, with a default value of the tolerance depending on the eigenvalues.
  
    Parameters
    ----------
    w : array-like, shape=(n_eigenvalues,)
      Eigenvalues to check for non semidefinite positiveness.
  
    tol : positive `float`, optional
      Negative eigenvalues above - tol are considered zero. If
      tol is None, and eps is the epsilon value for datatype of w, then tol
      is set to w.max() * len(w) * eps.
  
    See Also
    --------
    np.linalg.matrix_rank for more details on the choice of tolerance (the same
      strategy is applied here)