'Fits the GraphLasso covariance model to X.
Parameters
X : ndarray, shape (n_samples, n_features)
Data from which to compute the covariance estimate
y : (ignored)'

def fit(self, X, y=None):

    X = check_array(X, ensure_min_features=2, estimator=self)
    if self.assume_centered:
        self.location_ = np.zeros(X.shape[1])
    else:
        self.location_ = X.mean(0)
    emp_cov = empirical_covariance(X, assume_centered=self.assume_centered)
    cv = check_cv(self.cv, y, classifier=False)
    path = list()
    n_alphas = self.alphas
    inner_verbose = max(0, (self.verbose - 1))
    if isinstance(n_alphas, collections.Sequence):
        alphas = self.alphas
        n_refinements = 1
    else:
        n_refinements = self.n_refinements
        alpha_1 = alpha_max(emp_cov)
        alpha_0 = (0.01 * alpha_1)
        alphas = np.logspace(np.log10(alpha_0), np.log10(alpha_1), n_alphas)[::(-1)]
    t0 = time.time()
    for i in range(n_refinements):
        with warnings.catch_warnings():
            warnings.simplefilter('ignore', ConvergenceWarning)
            this_path = Parallel(n_jobs=self.n_jobs, verbose=self.verbose)((delayed(graph_lasso_path)(X[train], alphas=alphas, X_test=X[test], mode=self.mode, tol=self.tol, enet_tol=self.enet_tol, max_iter=int((0.1 * self.max_iter)), verbose=inner_verbose) for (train, test) in cv.split(X, y)))
        (covs, _, scores) = zip(*this_path)
        covs = zip(*covs)
        scores = zip(*scores)
        path.extend(zip(alphas, scores, covs))
        path = sorted(path, key=operator.itemgetter(0), reverse=True)
        best_score = (- np.inf)
        last_finite_idx = 0
        for (index, (alpha, scores, _)) in enumerate(path):
            this_score = np.mean(scores)
            if (this_score >= (0.1 / np.finfo(np.float64).eps)):
                this_score = np.nan
            if np.isfinite(this_score):
                last_finite_idx = index
            if (this_score >= best_score):
                best_score = this_score
                best_index = index
        if (best_index == 0):
            alpha_1 = path[0][0]
            alpha_0 = path[1][0]
        elif ((best_index == last_finite_idx) and (not (best_index == (len(path) - 1)))):
            alpha_1 = path[best_index][0]
            alpha_0 = path[(best_index + 1)][0]
        elif (best_index == (len(path) - 1)):
            alpha_1 = path[best_index][0]
            alpha_0 = (0.01 * path[best_index][0])
        else:
            alpha_1 = path[(best_index - 1)][0]
            alpha_0 = path[(best_index + 1)][0]
        if (not isinstance(n_alphas, collections.Sequence)):
            alphas = np.logspace(np.log10(alpha_1), np.log10(alpha_0), (n_alphas + 2))
            alphas = alphas[1:(-1)]
        if (self.verbose and (n_refinements > 1)):
            print ('[GraphLassoCV]    Done    refinement    %    2i    out    of    %i:    %    3is' % ((i + 1), n_refinements, (time.time() - t0)))
    path = list(zip(*path))
    grid_scores = list(path[1])
    alphas = list(path[0])
    alphas.append(0)
    grid_scores.append(cross_val_score(EmpiricalCovariance(), X, cv=cv, n_jobs=self.n_jobs, verbose=inner_verbose))
    self.grid_scores_ = np.array(grid_scores)
    best_alpha = alphas[best_index]
    self.alpha_ = best_alpha
    self.cv_alphas_ = alphas
    (self.covariance_, self.precision_, self.n_iter_) = graph_lasso(emp_cov, alpha=best_alpha, mode=self.mode, tol=self.tol, enet_tol=self.enet_tol, max_iter=self.max_iter, verbose=inner_verbose, return_n_iter=True)
    return self
