# Buggy code
def _fit(self, X):
    """Dispatch to the right submethod depending on the chosen solver."""

    # Raise an error for sparse input.
    # This is more informative than the generic one raised by check_array.
    if issparse(X):
        raise TypeError(
            "PCA does not support sparse input. See "
            "TruncatedSVD for a possible alternative."
        )

    X = check_array(X, dtype=[np.float64, np.float32], ensure_2d=True, copy=self.copy)

    # Handle n_components==None
    if self.n_components is None:
        if self.svd_solver != "arpack":
            n_components = min(X.shape)
        else:
            n_components = min(X.shape) - 1
    else:
        n_components = self.n_components

    # Handle svd_solver
    svd_solver = self.svd_solver
    if svd_solver == "auto":
        # Small problem, just call full PCA
        if max(X.shape) <= 500:
            svd_solver = "full"
        elif n_components >= 1 and n_components < 0.8 * min(X.shape):
            svd_solver = "randomized"
        # This is also the case of n_components in (0,1)
        else:
            svd_solver = "full"

    # Call different fits for either full or truncated SVD
    if svd_solver == "full":
        return self._fit_full(X, n_components)
    elif svd_solver in ["arpack", "randomized"]:
        return self._fit_truncated(X, n_components, svd_solver)
    else:
        raise ValueError("Unrecognized svd_solver='{0}'".format(svd_solver))


# Traceback (TypeError)
TypeError                                 Traceback (most recent call last)
<ipython-input-25-76d1451f7528> in <module>()
5 from sklearn.decomposition import PCA
6 pca = PCA(n_components='mle')
----> 7 pca.fit(X)
8
9 X2 = pca.transform(X)

/home/bigdata/anaconda3/lib/python3.6/site-packages/sklearn/decomposition/pca.py in fit(self, X, y)
305             Returns the instance itself.
306         """
--> 307         self._fit(X)
308         return self
309

/home/bigdata/anaconda3/lib/python3.6/site-packages/sklearn/decomposition/pca.py in _fit(self, X)
358             if max(X.shape) <= 500:
359                 svd_solver = 'full'
--> 360             elif n_components >= 1 and n_components < .8 * min(X.shape):
361                 svd_solver = 'randomized'
362             # This is also the case of n_components in (0,1)

TypeError: '>=' not supported between instances of 'str' and 'int'

# Fixed code
def _fit(self, X):
    """Dispatch to the right submethod depending on the chosen solver."""

    # Raise an error for sparse input.
    # This is more informative than the generic one raised by check_array.
    if issparse(X):
        raise TypeError(
            "PCA does not support sparse input. See "
            "TruncatedSVD for a possible alternative."
        )

    X = check_array(X, dtype=[np.float64, np.float32], ensure_2d=True, copy=self.copy)

    # Handle n_components==None
    if self.n_components is None:
        if self.svd_solver != "arpack":
            n_components = min(X.shape)
        else:
            n_components = min(X.shape) - 1
    else:
        n_components = self.n_components

    # Handle svd_solver
    svd_solver = self.svd_solver
    if svd_solver == "auto":
        # Small problem or n_components == 'mle', just call full PCA
        if max(X.shape) <= 500 or n_components == "mle":
            svd_solver = "full"
        elif n_components >= 1 and n_components < 0.8 * min(X.shape):
            svd_solver = "randomized"
        # This is also the case of n_components in (0,1)
        else:
            svd_solver = "full"

    # Call different fits for either full or truncated SVD
    if svd_solver == "full":
        return self._fit_full(X, n_components)
    elif svd_solver in ["arpack", "randomized"]:
        return self._fit_truncated(X, n_components, svd_solver)
    else:
        raise ValueError("Unrecognized svd_solver='{0}'".format(svd_solver))