import warnings

from distutils.version import LooseVersion

import numpy as np
import pytest
from scipy import linalg

from sklearn.model_selection import train_test_split
from sklearn.utils.testing import assert_allclose
from sklearn.utils.testing import assert_array_almost_equal
from sklearn.utils.testing import assert_equal
from sklearn.utils.testing import assert_less
from sklearn.utils.testing import assert_greater
from sklearn.utils.testing import assert_raises
from sklearn.utils.testing import ignore_warnings
from sklearn.utils.testing import assert_warns
from sklearn.utils.testing import TempMemmap
from sklearn.exceptions import ConvergenceWarning
from sklearn import linear_model, datasets
from sklearn.linear_model.least_angle import _lars_path_residues, LassoLarsIC

# TODO: use another dataset that has multiple drops
diabetes = datasets.load_diabetes()
X, y = diabetes.data, diabetes.target
G = np.dot(X.T, X)
Xy = np.dot(X.T, y)
n_samples = y.size


def test_simple():
    # Principle of Lars is to keep covariances tied and decreasing

    # also test verbose output
    from io import StringIO
    import sys
    old_stdout = sys.stdout
    try:
        sys.stdout = StringIO()

        _, _, coef_path_ = linear_model.lars_path(
            X, y, method='lar', verbose=10)

        sys.stdout = old_stdout

        for i, coef_ in enumerate(coef_path_.T):
            res = y - np.dot(X, coef_)
            cov = np.dot(X.T, res)
            C = np.max(abs(cov))
            eps = 1e-3
            ocur = len(cov[C - eps < abs(cov)])
            if i < X.shape[1]:
                assert ocur == i + 1
            else:
                # no more than max_pred variables can go into the active set
                assert ocur == X.shape[1]
    finally:
        sys.stdout = old_stdout


def test_simple_precomputed():
    # The same, with precomputed Gram matrix

    _, _, coef_path_ = linear_model.lars_path(
        X, y, Gram=G, method='lar')

    for i, coef_ in enumerate(coef_path_.T):
        res = y - np.dot(X, coef_)
        cov = np.dot(X.T, res)
        C = np.max(abs(cov))
        eps = 1e-3
        ocur = len(cov[C - eps < abs(cov)])
        if i < X.shape[1]:
            assert ocur == i + 1
        else:
            # no more than max_pred variables can go into the active set
            assert ocur == X.shape[1]


def _assert_same_lars_path_result(output1, output2):
    assert_equal(len(output1), len(output2))
    for o1, o2 in zip(output1, output2):
        assert_allclose(o1, o2)


@pytest.mark.parametrize('method', ['lar', 'lasso'])
@pytest.mark.parametrize('return_path', [True, False])
def test_lars_path_gram_equivalent(method, return_path):
    _assert_same_lars_path_result(
        linear_model.lars_path_gram(
            Xy=Xy, Gram=G, n_samples=n_samples, method=method,
            return_path=return_path),
        linear_model.lars_path(
            X, y, Gram=G, method=method,
            return_path=return_path))


def test_x_none_gram_none_raises_value_error():
    # Test that lars_path with no X and Gram raises exception
    Xy = np.dot(X.T, y)
    assert_raises(ValueError, linear_model.lars_path, None, y, Gram=None,
                  Xy=Xy)


def test_all_precomputed():
    # Test that lars_path with precomputed Gram and Xy gives the right answer
    G = np.dot(X.T, X)
    Xy = np.dot(X.T, y)
    for method in 'lar', 'lasso':
        output = linear_model.lars_path(X, y, method=method)
        output_pre = linear_model.lars_path(X, y, Gram=G, Xy=Xy,
                                            method=method)
        for expected, got in zip(output, output_pre):
            assert_array_almost_equal(expected, got)


@pytest.mark.filterwarnings('ignore: `rcond` parameter will change')
# numpy deprecation
def test_lars_lstsq():
    # Test that Lars gives least square solution at the end
    # of the path
    X1 = 3 * X  # use un-normalized dataset
    clf = linear_model.LassoLars(alpha=0.)
    clf.fit(X1, y)
    # Avoid FutureWarning about default value change when numpy >= 1.14
    rcond = None if LooseVersion(np.__version__) >= '1.14' else -1
    coef_lstsq = np.linalg.lstsq(X1, y, rcond=rcond)[0]
    assert_array_almost_equal(clf.coef_, coef_lstsq)


@pytest.mark.filterwarnings('ignore:`rcond` parameter will change')
# numpy deprecation
def test_lasso_gives_lstsq_solution():
    # Test that Lars Lasso gives least square solution at the end
    # of the path
    _, _, coef_path_ = linear_model.lars_path(X, y, method='lasso')
    coef_lstsq = np.linalg.lstsq(X, y)[0]
    assert_array_almost_equal(coef_lstsq, coef_path_[:, -1])


def test_collinearity():
    # Check that lars_path is robust to collinearity in input
    X = np.array([[3., 3., 1.],
                  [2., 2., 0.],
                  [1., 1., 0]])
    y = np.array([1., 0., 0])
    rng = np.random.RandomState(0)

    f = ignore_warnings
    _, _, coef_path_ = f(linear_model.lars_path)(X, y, alpha_min=0.01)
    assert not np.isnan(coef_path_).any()
    residual = np.dot(X, coef_path_[:, -1]) - y
    assert_less((residual ** 2).sum(), 1.)  # just make sure it's bounded

    n_samples = 10
    X = rng.rand(n_samples, 5)
    y = np.zeros(n_samples)
    _, _, coef_path_ = linear_model.lars_path(X, y, Gram='auto', copy_X=False,
                                              copy_Gram=False, alpha_min=0.,
                                              method='lasso', verbose=0,
                                              max_iter=500)
    assert_array_almost_equal(coef_path_, np.zeros_like(coef_path_))


def test_no_path():
    # Test that the ``return_path=False`` option returns the correct output
    alphas_, _, coef_path_ = linear_model.lars_path(
        X, y, method='lar')
    alpha_, _, coef = linear_model.lars_path(
        X, y, method='lar', return_path=False)

    assert_array_almost_equal(coef, coef_path_[:, -1])
    assert alpha_ == alphas_[-1]


def test_no_path_precomputed():
    # Test that the ``return_path=False`` option with Gram remains correct
    alphas_, _, coef_path_ = linear_model.lars_path(
        X, y, method='lar', Gram=G)
    alpha_, _, coef = linear_model.lars_path(
        X, y, method='lar', Gram=G, return_path=False)

    assert_array_almost_equal(coef, coef_path_[:, -1])
    assert alpha_ == alphas_[-1]


def test_no_path_all_precomputed():
    # Test that the ``return_path=False`` option with Gram and Xy remains
    # correct
    X, y = 3 * diabetes.data, diabetes.target
    G = np.dot(X.T, X)
    Xy = np.dot(X.T, y)
    alphas_, _, coef_path_ = linear_model.lars_path(
        X, y, method='lasso', Xy=Xy, Gram=G, alpha_min=0.9)
    alpha_, _, coef = linear_model.lars_path(
        X, y, method='lasso', Gram=G, Xy=Xy, alpha_min=0.9, return_path=False)

    assert_array_almost_equal(coef, coef_path_[:, -1])
    assert alpha_ == alphas_[-1]


@pytest.mark.filterwarnings('ignore: The default value of cv')  # 0.22
@pytest.mark.parametrize(
        'classifier',
        [linear_model.Lars, linear_model.LarsCV, linear_model.LassoLarsIC])
def test_lars_precompute(classifier):
    # Check for different values of precompute
    G = np.dot(X.T, X)

    clf = classifier(precompute=G)
    output_1 = ignore_warnings(clf.fit)(X, y).coef_
    for precompute in [True, False, 'auto', None]:
        clf = classifier(precompute=precompute)
        output_2 = clf.fit(X, y).coef_
        assert_array_almost_equal(output_1, output_2, decimal=8)


def test_singular_matrix():
    # Test when input is a singular matrix
    X1 = np.array([[1, 1.], [1., 1.]])
    y1 = np.array([1, 1])
    _, _, coef_path = linear_model.lars_path(X1, y1)
    assert_array_almost_equal(coef_path.T, [[0, 0], [1, 0]])


def test_rank_deficient_design():
    # consistency test that checks that LARS Lasso is handling rank
    # deficient input data (with n_features < rank) in the same way
    # as coordinate descent Lasso
    y = [5, 0, 5]
    for X in (
              [[5, 0],
               [0, 5],
               [10, 10]],
              [[10, 10, 0],
               [1e-32, 0, 0],
               [0, 0, 1]]
             ):
        # To be able to use the coefs to compute the objective function,
        # we need to turn off normalization
        lars = linear_model.LassoLars(.1, normalize=False)
        coef_lars_ = lars.fit(X, y).coef_
        obj_lars = (1. / (2. * 3.)
                    * linalg.norm(y - np.dot(X, coef_lars_)) ** 2
                    + .1 * linalg.norm(coef_lars_, 1))
        coord_descent = linear_model.Lasso(.1, tol=1e-6, normalize=False)
        coef_cd_ = coord_descent.fit(X, y).coef_
        obj_cd = ((1. / (2. * 3.)) * linalg.norm(y - np.dot(X, coef_cd_)) ** 2
                  + .1 * linalg.norm(coef_cd_, 1))
        assert_less(obj_lars, obj_cd * (1. + 1e-8))


def test_lasso_lars_vs_lasso_cd():
    # Test that LassoLars and Lasso using coordinate descent give the
    # same results.
    X = 3 * diabetes.data

    alphas, _, lasso_path = linear_model.lars_path(X, y, method='lasso')
    lasso_cd = linear_model.Lasso(fit_intercept=False, tol=1e-8)
    for c, a in zip(lasso_path.T, alphas):
        if a == 0:
            continue
        lasso_cd.alpha = a
        lasso_cd.fit(X, y)
        error = linalg.norm(c - lasso_cd.coef_)
        assert_less(error, 0.01)

    # similar test, with the classifiers
    for alpha in np.linspace(1e-2, 1 - 1e-2, 20):
        clf1 = linear_model.LassoLars(alpha=alpha, normalize=False).fit(X, y)
        clf2 = linear_model.Lasso(alpha=alpha, tol=1e-8,
                                  normalize=False).fit(X, y)
        err = linalg.norm(clf1.coef_ - clf2.coef_)
        assert_less(err, 1e-3)

    # same test, with normalized data
    X = diabetes.data
    alphas, _, lasso_path = linear_model.lars_path(X, y, method='lasso')
    lasso_cd = linear_model.Lasso(fit_intercept=False, normalize=True,
                                  tol=1e-8)
    for c, a in zip(lasso_path.T, alphas):
        if a == 0:
            continue
        lasso_cd.alpha = a
        lasso_cd.fit(X, y)
        error = linalg.norm(c - lasso_cd.coef_)
        assert_less(error, 0.01)


def test_lasso_lars_vs_lasso_cd_early_stopping():
    # Test that LassoLars and Lasso using coordinate descent give the
    # same results when early stopping is used.
    # (test : before, in the middle, and in the last part of the path)
    alphas_min = [10, 0.9, 1e-4]

    for alpha_min in alphas_min:
        alphas, _, lasso_path = linear_model.lars_path(X, y, method='lasso',
                                                       alpha_min=alpha_min)
        lasso_cd = linear_model.Lasso(fit_intercept=False, tol=1e-8)
        lasso_cd.alpha = alphas[-1]
        lasso_cd.fit(X, y)
        error = linalg.norm(lasso_path[:, -1] - lasso_cd.coef_)
        assert_less(error, 0.01)

    # same test, with normalization
    for alpha_min in alphas_min:
        alphas, _, lasso_path = linear_model.lars_path(X, y, method='lasso',
                                                       alpha_min=alpha_min)
        lasso_cd = linear_model.Lasso(fit_intercept=True, normalize=True,
                                      tol=1e-8)
        lasso_cd.alpha = alphas[-1]
        lasso_cd.fit(X, y)
        error = linalg.norm(lasso_path[:, -1] - lasso_cd.coef_)
        assert_less(error, 0.01)


def test_lasso_lars_path_length():
    # Test that the path length of the LassoLars is right
    lasso = linear_model.LassoLars()
    lasso.fit(X, y)
    lasso2 = linear_model.LassoLars(alpha=lasso.alphas_[2])
    lasso2.fit(X, y)
    assert_array_almost_equal(lasso.alphas_[:3], lasso2.alphas_)
    # Also check that the sequence of alphas is always decreasing
    assert np.all(np.diff(lasso.alphas_) < 0)


def test_lasso_lars_vs_lasso_cd_ill_conditioned():
    # Test lasso lars on a very ill-conditioned design, and check that
    # it does not blow up, and stays somewhat close to a solution given
    # by the coordinate descent solver
    # Also test that lasso_path (using lars_path output style) gives
    # the same result as lars_path and previous lasso output style
    # under these conditions.
    rng = np.random.RandomState(42)

    # Generate data
    n, m = 70, 100
    k = 5
    X = rng.randn(n, m)
    w = np.zeros((m, 1))
    i = np.arange(0, m)
    rng.shuffle(i)
    supp = i[:k]
    w[supp] = np.sign(rng.randn(k, 1)) * (rng.rand(k, 1) + 1)
    y = np.dot(X, w)
    sigma = 0.2
    y += sigma * rng.rand(*y.shape)
    y = y.squeeze()
    lars_alphas, _, lars_coef = linear_model.lars_path(X, y, method='lasso')

    _, lasso_coef2, _ = linear_model.lasso_path(X, y,
                                                alphas=lars_alphas,
                                                tol=1e-6,
                                                fit_intercept=False)

    assert_array_almost_equal(lars_coef, lasso_coef2, decimal=1)


def test_lasso_lars_vs_lasso_cd_ill_conditioned2():
    # Create an ill-conditioned situation in which the LARS has to go
    # far in the path to converge, and check that LARS and coordinate
    # descent give the same answers
    # Note it used to be the case that Lars had to use the drop for good
    # strategy for this but this is no longer the case with the
    # equality_tolerance checks
    X = [[1e20, 1e20, 0],
         [-1e-32, 0, 0],
         [1, 1, 1]]
    y = [10, 10, 1]
    alpha = .0001

    def objective_function(coef):
        return (1. / (2. * len(X)) * linalg.norm(y - np.dot(X, coef)) ** 2
                + alpha * linalg.norm(coef, 1))

    lars = linear_model.LassoLars(alpha=alpha, normalize=False)
    assert_warns(ConvergenceWarning, lars.fit, X, y)
    lars_coef_ = lars.coef_
    lars_obj = objective_function(lars_coef_)

    coord_descent = linear_model.Lasso(alpha=alpha, tol=1e-4, normalize=False)
    cd_coef_ = coord_descent.fit(X, y).coef_
    cd_obj = objective_function(cd_coef_)

    assert_less(lars_obj, cd_obj * (1. + 1e-8))


def test_lars_add_features():
    # assure that at least some features get added if necessary
    # test for 6d2b4c
    # Hilbert matrix
    n = 5
    H = 1. / (np.arange(1, n + 1) + np.arange(n)[:, np.newaxis])
    clf = linear_model.Lars(fit_intercept=False).fit(
        H, np.arange(n))
    assert np.all(np.isfinite(clf.coef_))


def test_lars_n_nonzero_coefs(verbose=False):
    lars = linear_model.Lars(n_nonzero_coefs=6, verbose=verbose)
    lars.fit(X, y)
    assert_equal(len(lars.coef_.nonzero()[0]), 6)
    # The path should be of length 6 + 1 in a Lars going down to 6
    # non-zero coefs
    assert_equal(len(lars.alphas_), 7)


@ignore_warnings
def test_multitarget():
    # Assure that estimators receiving multidimensional y do the right thing
    Y = np.vstack([y, y ** 2]).T
    n_targets = Y.shape[1]
    estimators = [
        linear_model.LassoLars(),
        linear_model.Lars(),
        # regression test for gh-1615
        linear_model.LassoLars(fit_intercept=False),
        linear_model.Lars(fit_intercept=False),
    ]

    for estimator in estimators:
        estimator.fit(X, Y)
        Y_pred = estimator.predict(X)
        alphas, active, coef, path = (estimator.alphas_, estimator.active_,
                                      estimator.coef_, estimator.coef_path_)
        for k in range(n_targets):
            estimator.fit(X, Y[:, k])
            y_pred = estimator.predict(X)
            assert_array_almost_equal(alphas[k], estimator.alphas_)
            assert_array_almost_equal(active[k], estimator.active_)
            assert_array_almost_equal(coef[k], estimator.coef_)
            assert_array_almost_equal(path[k], estimator.coef_path_)
            assert_array_almost_equal(Y_pred[:, k], y_pred)


@pytest.mark.filterwarnings('ignore: The default value of cv')  # 0.22
def test_lars_cv():
    # Test the LassoLarsCV object by checking that the optimal alpha
    # increases as the number of samples increases.
    # This property is not actually guaranteed in general and is just a
    # property of the given dataset, with the given steps chosen.
    old_alpha = 0
    lars_cv = linear_model.LassoLarsCV()
    for length in (400, 200, 100):
        X = diabetes.data[:length]
        y = diabetes.target[:length]
        lars_cv.fit(X, y)
        np.testing.assert_array_less(old_alpha, lars_cv.alpha_)
        old_alpha = lars_cv.alpha_
    assert not hasattr(lars_cv, 'n_nonzero_coefs')


@pytest.mark.filterwarnings('ignore::FutureWarning')
def test_lars_cv_max_iter():
    with warnings.catch_warnings(record=True) as w:
        rng = np.random.RandomState(42)
        x = rng.randn(len(y))
        X = diabetes.data
        X = np.c_[X, x, x]  # add correlated features
        lars_cv = linear_model.LassoLarsCV(max_iter=5)
        lars_cv.fit(X, y)
    assert len(w) == 0


def test_lasso_lars_ic():
    # Test the LassoLarsIC object by checking that
    # - some good features are selected.
    # - alpha_bic > alpha_aic
    # - n_nonzero_bic < n_nonzero_aic
    lars_bic = linear_model.LassoLarsIC('bic')
    lars_aic = linear_model.LassoLarsIC('aic')
    rng = np.random.RandomState(42)
    X = diabetes.data
    X = np.c_[X, rng.randn(X.shape[0], 5)]  # add 5 bad features
    lars_bic.fit(X, y)
    lars_aic.fit(X, y)
    nonzero_bic = np.where(lars_bic.coef_)[0]
    nonzero_aic = np.where(lars_aic.coef_)[0]
    assert_greater(lars_bic.alpha_, lars_aic.alpha_)
    assert_less(len(nonzero_bic), len(nonzero_aic))
    assert_less(np.max(nonzero_bic), diabetes.data.shape[1])

    # test error on unknown IC
    lars_broken = linear_model.LassoLarsIC('<unknown>')
    assert_raises(ValueError, lars_broken.fit, X, y)


def test_lars_path_readonly_data():
    # When using automated memory mapping on large input, the
    # fold data is in read-only mode
    # This is a non-regression test for:
    # https://github.com/scikit-learn/scikit-learn/issues/4597
    splitted_data = train_test_split(X, y, random_state=42)
    with TempMemmap(splitted_data) as (X_train, X_test, y_train, y_test):
        # The following should not fail despite copy=False
        _lars_path_residues(X_train, y_train, X_test, y_test, copy=False)


@pytest.mark.filterwarnings('ignore: The default of the `iid`')  # 0.22
def test_lars_path_positive_constraint():
    # this is the main test for the positive parameter on the lars_path method
    # the estimator classes just make use of this function

    # we do the test on the diabetes dataset

    # ensure that we get negative coefficients when positive=False
    # and all positive when positive=True
    # for method 'lar' (default) and lasso

    # Once deprecation of LAR + positive option is done use these:
    # assert_raises(ValueError, linear_model.lars_path, diabetes['data'],
    #               diabetes['target'], method='lar', positive=True)
    with pytest.warns(DeprecationWarning, match='broken'):
        linear_model.lars_path(diabetes['data'], diabetes['target'],
                               return_path=True, method='lar',
                               positive=True)
    method = 'lasso'
    _, _, coefs = \
        linear_model.lars_path(X, y, return_path=True, method=method,
                               positive=False)
    assert coefs.min() < 0

    _, _, coefs = \
        linear_model.lars_path(X, y, return_path=True, method=method,
                               positive=True)
    assert coefs.min() >= 0


# now we gonna test the positive option for all estimator classes

default_parameter = {'fit_intercept': False}

estimator_parameter_map = {'LassoLars': {'alpha': 0.1},
                           'LassoLarsCV': {},
                           'LassoLarsIC': {}}


@pytest.mark.filterwarnings('ignore: The default value of cv')  # 0.22
def test_estimatorclasses_positive_constraint():
    # testing the transmissibility for the positive option of all estimator
    # classes in this same function here
    default_parameter = {'fit_intercept': False}

    estimator_parameter_map = {'LassoLars': {'alpha': 0.1},
                               'LassoLarsCV': {},
                               'LassoLarsIC': {}}
    for estname in estimator_parameter_map:
        params = default_parameter.copy()
        params.update(estimator_parameter_map[estname])
        estimator = getattr(linear_model, estname)(positive=False, **params)
        estimator.fit(X, y)
        assert estimator.coef_.min() < 0
        estimator = getattr(linear_model, estname)(positive=True, **params)
        estimator.fit(X, y)
        assert min(estimator.coef_) >= 0


def test_lasso_lars_vs_lasso_cd_positive():
    # Test that LassoLars and Lasso using coordinate descent give the
    # same results when using the positive option

    # This test is basically a copy of the above with additional positive
    # option. However for the middle part, the comparison of coefficient values
    # for a range of alphas, we had to make an adaptations. See below.

    # not normalized data
    X = 3 * diabetes.data

    alphas, _, lasso_path = linear_model.lars_path(X, y, method='lasso',
                                                   positive=True)
    lasso_cd = linear_model.Lasso(fit_intercept=False, tol=1e-8, positive=True)
    for c, a in zip(lasso_path.T, alphas):
        if a == 0:
            continue
        lasso_cd.alpha = a
        lasso_cd.fit(X, y)
        error = linalg.norm(c - lasso_cd.coef_)
        assert_less(error, 0.01)

    # The range of alphas chosen for coefficient comparison here is restricted
    # as compared with the above test without the positive option. This is due
    # to the circumstance that the Lars-Lasso algorithm does not converge to
    # the least-squares-solution for small alphas, see 'Least Angle Regression'
    # by Efron et al 2004. The coefficients are typically in congruence up to
    # the smallest alpha reached by the Lars-Lasso algorithm and start to
    # diverge thereafter.  See
    # https://gist.github.com/michigraber/7e7d7c75eca694c7a6ff

    for alpha in np.linspace(6e-1, 1 - 1e-2, 20):
        clf1 = linear_model.LassoLars(fit_intercept=False, alpha=alpha,
                                      normalize=False, positive=True).fit(X, y)
        clf2 = linear_model.Lasso(fit_intercept=False, alpha=alpha, tol=1e-8,
                                  normalize=False, positive=True).fit(X, y)
        err = linalg.norm(clf1.coef_ - clf2.coef_)
        assert_less(err, 1e-3)

    # normalized data
    X = diabetes.data
    alphas, _, lasso_path = linear_model.lars_path(X, y, method='lasso',
                                                   positive=True)
    lasso_cd = linear_model.Lasso(fit_intercept=False, normalize=True,
                                  tol=1e-8, positive=True)
    for c, a in zip(lasso_path.T[:-1], alphas[:-1]):  # don't include alpha=0
        lasso_cd.alpha = a
        lasso_cd.fit(X, y)
        error = linalg.norm(c - lasso_cd.coef_)
        assert_less(error, 0.01)


def test_lasso_lars_vs_R_implementation():
    # Test that sklearn LassoLars implementation agrees with the LassoLars
    # implementation available in R (lars library) under the following
    # scenarios:
    # 1) fit_intercept=False and normalize=False
    # 2) fit_intercept=True and normalize=True

    # Let's generate the data used in the bug report 7778
    y = np.array([-6.45006793, -3.51251449, -8.52445396, 6.12277822,
                  -19.42109366])
    x = np.array([[0.47299829, 0, 0, 0, 0],
                  [0.08239882, 0.85784863, 0, 0, 0],
                  [0.30114139, -0.07501577, 0.80895216, 0, 0],
                  [-0.01460346, -0.1015233, 0.0407278, 0.80338378, 0],
                  [-0.69363927, 0.06754067, 0.18064514, -0.0803561,
                   0.40427291]])

    X = x.T

    ###########################################################################
    # Scenario 1: Let's compare R vs sklearn when fit_intercept=False and
    # normalize=False
    ###########################################################################
    #
    # The R result was obtained using the following code:
    #
    # library(lars)
    # model_lasso_lars = lars(X, t(y), type="lasso", intercept=FALSE,
    #                         trace=TRUE, normalize=FALSE)
    # r = t(model_lasso_lars$beta)
    #

    r = np.array([[0, 0, 0, 0, 0, -79.810362809499026, -83.528788732782829,
                   -83.777653739190711, -83.784156932888934,
                   -84.033390591756657],
                  [0, 0, 0, 0, -0.476624256777266, 0, 0, 0, 0,
                   0.025219751009936],
                  [0, -3.577397088285891, -4.702795355871871,
                   -7.016748621359461, -7.614898471899412, -0.336938391359179,
                   0, 0, 0.001213370600853, 0.048162321585148],
                  [0, 0, 0, 2.231558436628169, 2.723267514525966,
                   2.811549786389614, 2.813766976061531, 2.817462468949557,
                   2.817368178703816, 2.816221090636795],
                  [0, 0, -1.218422599914637, -3.457726183014808,
                   -4.021304522060710, -45.827461592423745,
                   -47.776608869312305,
                   -47.911561610746404, -47.914845922736234,
                   -48.039562334265717]])

    model_lasso_lars = linear_model.LassoLars(alpha=0, fit_intercept=False,
                                              normalize=False)
    model_lasso_lars.fit(X, y)
    skl_betas = model_lasso_lars.coef_path_

    assert_array_almost_equal(r, skl_betas, decimal=12)
    ###########################################################################

    ###########################################################################
    # Scenario 2: Let's compare R vs sklearn when fit_intercept=True and
    # normalize=True
    #
    # Note: When normalize is equal to True, R returns the coefficients in
    # their original units, that is, they are rescaled back, whereas sklearn
    # does not do that, therefore, we need to do this step before comparing
    # their results.
    ###########################################################################
    #
    # The R result was obtained using the following code:
    #
    # library(lars)
    # model_lasso_lars2 = lars(X, t(y), type="lasso", intercept=TRUE,
    #                           trace=TRUE, normalize=TRUE)
    # r2 = t(model_lasso_lars2$beta)

    r2 = np.array([[0, 0, 0, 0, 0],
                   [0, 0, 0, 8.371887668009453, 19.463768371044026],
                   [0, 0, 0, 0, 9.901611055290553],
                   [0, 7.495923132833733, 9.245133544334507,
                    17.389369207545062, 26.971656815643499],
                   [0, 0, -1.569380717440311, -5.924804108067312,
                    -7.996385265061972]])

    model_lasso_lars2 = linear_model.LassoLars(alpha=0, fit_intercept=True,
                                               normalize=True)
    model_lasso_lars2.fit(X, y)
    skl_betas2 = model_lasso_lars2.coef_path_

    # Let's rescale back the coefficients returned by sklearn before comparing
    # against the R result (read the note above)
    temp = X - np.mean(X, axis=0)
    normx = np.sqrt(np.sum(temp ** 2, axis=0))
    skl_betas2 /= normx[:, np.newaxis]

    assert_array_almost_equal(r2, skl_betas2, decimal=12)
    ###########################################################################


@pytest.mark.parametrize('copy_X', [True, False])
def test_lasso_lars_copyX_behaviour(copy_X):
    """
    Test that user input regarding copy_X is not being overridden (it was until
    at least version 0.21)

    """
    lasso_lars = LassoLarsIC(copy_X=copy_X, precompute=False)
    rng = np.random.RandomState(0)
    X = rng.normal(0, 1, (100, 5))
    X_copy = X.copy()
    y = X[:, 2]
    lasso_lars.fit(X, y)
    assert copy_X == np.array_equal(X, X_copy)


@pytest.mark.parametrize('copy_X', [True, False])
def test_lasso_lars_fit_copyX_behaviour(copy_X):
    """
    Test that user input to .fit for copy_X overrides default __init__ value

    """
    lasso_lars = LassoLarsIC(precompute=False)
    rng = np.random.RandomState(0)
    X = rng.normal(0, 1, (100, 5))
    X_copy = X.copy()
    y = X[:, 2]
    lasso_lars.fit(X, y, copy_X=copy_X)
    assert copy_X == np.array_equal(X, X_copy)

[((850, 874), 'sklearn.datasets.load_diabetes', 'datasets.load_diabetes', ([], {}), '()\n', (872, 874), False, 'from sklearn import linear_model, datasets\n'), ((917, 931), 'numpy.dot', 'np.dot', (['X.T', 'X'], {}), '(X.T, X)\n', (923, 931), True, 'import numpy as np\n'), ((937, 951), 'numpy.dot', 'np.dot', (['X.T', 'y'], {}), '(X.T, y)\n', (943, 951), True, 'import numpy as np\n'), ((2537, 2588), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""method"""', "['lar', 'lasso']"], {}), "('method', ['lar', 'lasso'])\n", (2560, 2588), False, 'import pytest\n'), ((2590, 2643), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""return_path"""', '[True, False]'], {}), "('return_path', [True, False])\n", (2613, 2643), False, 'import pytest\n'), ((3704, 3771), 'pytest.mark.filterwarnings', 'pytest.mark.filterwarnings', (['"""ignore: `rcond` parameter will change"""'], {}), "('ignore: `rcond` parameter will change')\n", (3730, 3771), False, 'import pytest\n'), ((4250, 4316), 'pytest.mark.filterwarnings', 'pytest.mark.filterwarnings', (['"""ignore:`rcond` parameter will change"""'], {}), "('ignore:`rcond` parameter will change')\n", (4276, 4316), False, 'import pytest\n'), ((6876, 6937), 'pytest.mark.filterwarnings', 'pytest.mark.filterwarnings', (['"""ignore: The default value of cv"""'], {}), "('ignore: The default value of cv')\n", (6902, 6937), False, 'import pytest\n'), ((6947, 7057), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""classifier"""', '[linear_model.Lars, linear_model.LarsCV, linear_model.LassoLarsIC]'], {}), "('classifier', [linear_model.Lars, linear_model.\n    LarsCV, linear_model.LassoLarsIC])\n", (6970, 7057), False, 'import pytest\n'), ((15732, 15793), 'pytest.mark.filterwarnings', 'pytest.mark.filterwarnings', (['"""ignore: The default value of cv"""'], {}), "('ignore: The default value of cv')\n", (15758, 15793), False, 'import pytest\n'), ((16426, 16477), 'pytest.mark.filterwarnings', 'pytest.mark.filterwarnings', (['"""ignore::FutureWarning"""'], {}), "('ignore::FutureWarning')\n", (16452, 16477), False, 'import pytest\n'), ((18174, 18236), 'pytest.mark.filterwarnings', 'pytest.mark.filterwarnings', (['"""ignore: The default of the `iid`"""'], {}), "('ignore: The default of the `iid`')\n", (18200, 18236), False, 'import pytest\n'), ((19688, 19749), 'pytest.mark.filterwarnings', 'pytest.mark.filterwarnings', (['"""ignore: The default value of cv"""'], {}), "('ignore: The default value of cv')\n", (19714, 19749), False, 'import pytest\n'), ((27375, 27423), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""copy_X"""', '[True, False]'], {}), "('copy_X', [True, False])\n", (27398, 27423), False, 'import pytest\n'), ((27838, 27886), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""copy_X"""', '[True, False]'], {}), "('copy_X', [True, False])\n", (27861, 27886), False, 'import pytest\n'), ((1912, 1962), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'Gram': 'G', 'method': '"""lar"""'}), "(X, y, Gram=G, method='lar')\n", (1934, 1962), False, 'from sklearn import linear_model, datasets\n'), ((3106, 3120), 'numpy.dot', 'np.dot', (['X.T', 'y'], {}), '(X.T, y)\n', (3112, 3120), True, 'import numpy as np\n'), ((3125, 3201), 'sklearn.utils.testing.assert_raises', 'assert_raises', (['ValueError', 'linear_model.lars_path', 'None', 'y'], {'Gram': 'None', 'Xy': 'Xy'}), '(ValueError, linear_model.lars_path, None, y, Gram=None, Xy=Xy)\n', (3138, 3201), False, 'from sklearn.utils.testing import assert_raises\n'), ((3336, 3350), 'numpy.dot', 'np.dot', (['X.T', 'X'], {}), '(X.T, X)\n', (3342, 3350), True, 'import numpy as np\n'), ((3360, 3374), 'numpy.dot', 'np.dot', (['X.T', 'y'], {}), '(X.T, y)\n', (3366, 3374), True, 'import numpy as np\n'), ((3947, 3980), 'sklearn.linear_model.LassoLars', 'linear_model.LassoLars', ([], {'alpha': '(0.0)'}), '(alpha=0.0)\n', (3969, 3980), False, 'from sklearn import linear_model, datasets\n'), ((4198, 4246), 'sklearn.utils.testing.assert_array_almost_equal', 'assert_array_almost_equal', (['clf.coef_', 'coef_lstsq'], {}), '(clf.coef_, coef_lstsq)\n', (4223, 4246), False, 'from sklearn.utils.testing import assert_array_almost_equal\n'), ((4483, 4527), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'method': '"""lasso"""'}), "(X, y, method='lasso')\n", (4505, 4527), False, 'from sklearn import linear_model, datasets\n'), ((4574, 4632), 'sklearn.utils.testing.assert_array_almost_equal', 'assert_array_almost_equal', (['coef_lstsq', 'coef_path_[:, (-1)]'], {}), '(coef_lstsq, coef_path_[:, (-1)])\n', (4599, 4632), False, 'from sklearn.utils.testing import assert_array_almost_equal\n'), ((4728, 4787), 'numpy.array', 'np.array', (['[[3.0, 3.0, 1.0], [2.0, 2.0, 0.0], [1.0, 1.0, 0]]'], {}), '([[3.0, 3.0, 1.0], [2.0, 2.0, 0.0], [1.0, 1.0, 0]])\n', (4736, 4787), True, 'import numpy as np\n'), ((4824, 4847), 'numpy.array', 'np.array', (['[1.0, 0.0, 0]'], {}), '([1.0, 0.0, 0])\n', (4832, 4847), True, 'import numpy as np\n'), ((4856, 4880), 'numpy.random.RandomState', 'np.random.RandomState', (['(0)'], {}), '(0)\n', (4877, 4880), True, 'import numpy as np\n'), ((5200, 5219), 'numpy.zeros', 'np.zeros', (['n_samples'], {}), '(n_samples)\n', (5208, 5219), True, 'import numpy as np\n'), ((5243, 5375), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'Gram': '"""auto"""', 'copy_X': '(False)', 'copy_Gram': '(False)', 'alpha_min': '(0.0)', 'method': '"""lasso"""', 'verbose': '(0)', 'max_iter': '(500)'}), "(X, y, Gram='auto', copy_X=False, copy_Gram=False,\n    alpha_min=0.0, method='lasso', verbose=0, max_iter=500)\n", (5265, 5375), False, 'from sklearn import linear_model, datasets\n'), ((5705, 5747), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'method': '"""lar"""'}), "(X, y, method='lar')\n", (5727, 5747), False, 'from sklearn import linear_model, datasets\n'), ((5779, 5840), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'method': '"""lar"""', 'return_path': '(False)'}), "(X, y, method='lar', return_path=False)\n", (5801, 5840), False, 'from sklearn import linear_model, datasets\n'), ((5855, 5907), 'sklearn.utils.testing.assert_array_almost_equal', 'assert_array_almost_equal', (['coef', 'coef_path_[:, (-1)]'], {}), '(coef, coef_path_[:, (-1)])\n', (5880, 5907), False, 'from sklearn.utils.testing import assert_array_almost_equal\n'), ((6077, 6127), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'method': '"""lar"""', 'Gram': 'G'}), "(X, y, method='lar', Gram=G)\n", (6099, 6127), False, 'from sklearn import linear_model, datasets\n'), ((6159, 6228), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'method': '"""lar"""', 'Gram': 'G', 'return_path': '(False)'}), "(X, y, method='lar', Gram=G, return_path=False)\n", (6181, 6228), False, 'from sklearn import linear_model, datasets\n'), ((6243, 6295), 'sklearn.utils.testing.assert_array_almost_equal', 'assert_array_almost_equal', (['coef', 'coef_path_[:, (-1)]'], {}), '(coef, coef_path_[:, (-1)])\n', (6268, 6295), False, 'from sklearn.utils.testing import assert_array_almost_equal\n'), ((6507, 6521), 'numpy.dot', 'np.dot', (['X.T', 'X'], {}), '(X.T, X)\n', (6513, 6521), True, 'import numpy as np\n'), ((6531, 6545), 'numpy.dot', 'np.dot', (['X.T', 'y'], {}), '(X.T, y)\n', (6537, 6545), True, 'import numpy as np\n'), ((6575, 6649), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'method': '"""lasso"""', 'Xy': 'Xy', 'Gram': 'G', 'alpha_min': '(0.9)'}), "(X, y, method='lasso', Xy=Xy, Gram=G, alpha_min=0.9)\n", (6597, 6649), False, 'from sklearn import linear_model, datasets\n'), ((6681, 6778), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'method': '"""lasso"""', 'Gram': 'G', 'Xy': 'Xy', 'alpha_min': '(0.9)', 'return_path': '(False)'}), "(X, y, method='lasso', Gram=G, Xy=Xy, alpha_min=0.9,\n    return_path=False)\n", (6703, 6778), False, 'from sklearn import linear_model, datasets\n'), ((6789, 6841), 'sklearn.utils.testing.assert_array_almost_equal', 'assert_array_almost_equal', (['coef', 'coef_path_[:, (-1)]'], {}), '(coef, coef_path_[:, (-1)])\n', (6814, 6841), False, 'from sklearn.utils.testing import assert_array_almost_equal\n'), ((7163, 7177), 'numpy.dot', 'np.dot', (['X.T', 'X'], {}), '(X.T, X)\n', (7169, 7177), True, 'import numpy as np\n'), ((7551, 7583), 'numpy.array', 'np.array', (['[[1, 1.0], [1.0, 1.0]]'], {}), '([[1, 1.0], [1.0, 1.0]])\n', (7559, 7583), True, 'import numpy as np\n'), ((7590, 7606), 'numpy.array', 'np.array', (['[1, 1]'], {}), '([1, 1])\n', (7598, 7606), True, 'import numpy as np\n'), ((7629, 7659), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X1', 'y1'], {}), '(X1, y1)\n', (7651, 7659), False, 'from sklearn import linear_model, datasets\n'), ((7664, 7720), 'sklearn.utils.testing.assert_array_almost_equal', 'assert_array_almost_equal', (['coef_path.T', '[[0, 0], [1, 0]]'], {}), '(coef_path.T, [[0, 0], [1, 0]])\n', (7689, 7720), False, 'from sklearn.utils.testing import assert_array_almost_equal\n'), ((8993, 9037), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'method': '"""lasso"""'}), "(X, y, method='lasso')\n", (9015, 9037), False, 'from sklearn import linear_model, datasets\n'), ((9053, 9103), 'sklearn.linear_model.Lasso', 'linear_model.Lasso', ([], {'fit_intercept': '(False)', 'tol': '(1e-08)'}), '(fit_intercept=False, tol=1e-08)\n', (9071, 9103), False, 'from sklearn import linear_model, datasets\n'), ((9380, 9411), 'numpy.linspace', 'np.linspace', (['(0.01)', '(1 - 0.01)', '(20)'], {}), '(0.01, 1 - 0.01, 20)\n', (9391, 9411), True, 'import numpy as np\n'), ((9780, 9824), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'method': '"""lasso"""'}), "(X, y, method='lasso')\n", (9802, 9824), False, 'from sklearn import linear_model, datasets\n'), ((9840, 9906), 'sklearn.linear_model.Lasso', 'linear_model.Lasso', ([], {'fit_intercept': '(False)', 'normalize': '(True)', 'tol': '(1e-08)'}), '(fit_intercept=False, normalize=True, tol=1e-08)\n', (9858, 9906), False, 'from sklearn import linear_model, datasets\n'), ((11460, 11484), 'sklearn.linear_model.LassoLars', 'linear_model.LassoLars', ([], {}), '()\n', (11482, 11484), False, 'from sklearn import linear_model, datasets\n'), ((11518, 11564), 'sklearn.linear_model.LassoLars', 'linear_model.LassoLars', ([], {'alpha': 'lasso.alphas_[2]'}), '(alpha=lasso.alphas_[2])\n', (11540, 11564), False, 'from sklearn import linear_model, datasets\n'), ((11590, 11650), 'sklearn.utils.testing.assert_array_almost_equal', 'assert_array_almost_equal', (['lasso.alphas_[:3]', 'lasso2.alphas_'], {}), '(lasso.alphas_[:3], lasso2.alphas_)\n', (11615, 11650), False, 'from sklearn.utils.testing import assert_array_almost_equal\n'), ((12174, 12199), 'numpy.random.RandomState', 'np.random.RandomState', (['(42)'], {}), '(42)\n', (12195, 12199), True, 'import numpy as np\n'), ((12282, 12298), 'numpy.zeros', 'np.zeros', (['(m, 1)'], {}), '((m, 1))\n', (12290, 12298), True, 'import numpy as np\n'), ((12307, 12322), 'numpy.arange', 'np.arange', (['(0)', 'm'], {}), '(0, m)\n', (12316, 12322), True, 'import numpy as np\n'), ((12429, 12441), 'numpy.dot', 'np.dot', (['X', 'w'], {}), '(X, w)\n', (12435, 12441), True, 'import numpy as np\n'), ((12546, 12590), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'method': '"""lasso"""'}), "(X, y, method='lasso')\n", (12568, 12590), False, 'from sklearn import linear_model, datasets\n'), ((12616, 12702), 'sklearn.linear_model.lasso_path', 'linear_model.lasso_path', (['X', 'y'], {'alphas': 'lars_alphas', 'tol': '(1e-06)', 'fit_intercept': '(False)'}), '(X, y, alphas=lars_alphas, tol=1e-06, fit_intercept=\n    False)\n', (12639, 12702), False, 'from sklearn import linear_model, datasets\n'), ((12846, 12906), 'sklearn.utils.testing.assert_array_almost_equal', 'assert_array_almost_equal', (['lars_coef', 'lasso_coef2'], {'decimal': '(1)'}), '(lars_coef, lasso_coef2, decimal=1)\n', (12871, 12906), False, 'from sklearn.utils.testing import assert_array_almost_equal\n'), ((13585, 13637), 'sklearn.linear_model.LassoLars', 'linear_model.LassoLars', ([], {'alpha': 'alpha', 'normalize': '(False)'}), '(alpha=alpha, normalize=False)\n', (13607, 13637), False, 'from sklearn import linear_model, datasets\n'), ((13642, 13690), 'sklearn.utils.testing.assert_warns', 'assert_warns', (['ConvergenceWarning', 'lars.fit', 'X', 'y'], {}), '(ConvergenceWarning, lars.fit, X, y)\n', (13654, 13690), False, 'from sklearn.utils.testing import assert_warns\n'), ((13786, 13846), 'sklearn.linear_model.Lasso', 'linear_model.Lasso', ([], {'alpha': 'alpha', 'tol': '(0.0001)', 'normalize': '(False)'}), '(alpha=alpha, tol=0.0001, normalize=False)\n', (13804, 13846), False, 'from sklearn import linear_model, datasets\n'), ((13937, 13982), 'sklearn.utils.testing.assert_less', 'assert_less', (['lars_obj', '(cd_obj * (1.0 + 1e-08))'], {}), '(lars_obj, cd_obj * (1.0 + 1e-08))\n', (13948, 13982), False, 'from sklearn.utils.testing import assert_less\n'), ((14375, 14428), 'sklearn.linear_model.Lars', 'linear_model.Lars', ([], {'n_nonzero_coefs': '(6)', 'verbose': 'verbose'}), '(n_nonzero_coefs=6, verbose=verbose)\n', (14392, 14428), False, 'from sklearn import linear_model, datasets\n'), ((16113, 16139), 'sklearn.linear_model.LassoLarsCV', 'linear_model.LassoLarsCV', ([], {}), '()\n', (16137, 16139), False, 'from sklearn import linear_model, datasets\n'), ((17016, 17047), 'sklearn.linear_model.LassoLarsIC', 'linear_model.LassoLarsIC', (['"""bic"""'], {}), "('bic')\n", (17040, 17047), False, 'from sklearn import linear_model, datasets\n'), ((17063, 17094), 'sklearn.linear_model.LassoLarsIC', 'linear_model.LassoLarsIC', (['"""aic"""'], {}), "('aic')\n", (17087, 17094), False, 'from sklearn import linear_model, datasets\n'), ((17105, 17130), 'numpy.random.RandomState', 'np.random.RandomState', (['(42)'], {}), '(42)\n', (17126, 17130), True, 'import numpy as np\n'), ((17360, 17408), 'sklearn.utils.testing.assert_greater', 'assert_greater', (['lars_bic.alpha_', 'lars_aic.alpha_'], {}), '(lars_bic.alpha_, lars_aic.alpha_)\n', (17374, 17408), False, 'from sklearn.utils.testing import assert_greater\n'), ((17572, 17609), 'sklearn.linear_model.LassoLarsIC', 'linear_model.LassoLarsIC', (['"""<unknown>"""'], {}), "('<unknown>')\n", (17596, 17609), False, 'from sklearn import linear_model, datasets\n'), ((17614, 17662), 'sklearn.utils.testing.assert_raises', 'assert_raises', (['ValueError', 'lars_broken.fit', 'X', 'y'], {}), '(ValueError, lars_broken.fit, X, y)\n', (17627, 17662), False, 'from sklearn.utils.testing import assert_raises\n'), ((17924, 17963), 'sklearn.model_selection.train_test_split', 'train_test_split', (['X', 'y'], {'random_state': '(42)'}), '(X, y, random_state=42)\n', (17940, 17963), False, 'from sklearn.model_selection import train_test_split\n'), ((19121, 19198), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'return_path': '(True)', 'method': 'method', 'positive': '(False)'}), '(X, y, return_path=True, method=method, positive=False)\n', (19143, 19198), False, 'from sklearn import linear_model, datasets\n'), ((19286, 19362), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'return_path': '(True)', 'method': 'method', 'positive': '(True)'}), '(X, y, return_path=True, method=method, positive=True)\n', (19308, 19362), False, 'from sklearn import linear_model, datasets\n'), ((21041, 21100), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'method': '"""lasso"""', 'positive': '(True)'}), "(X, y, method='lasso', positive=True)\n", (21063, 21100), False, 'from sklearn import linear_model, datasets\n'), ((21167, 21232), 'sklearn.linear_model.Lasso', 'linear_model.Lasso', ([], {'fit_intercept': '(False)', 'tol': '(1e-08)', 'positive': '(True)'}), '(fit_intercept=False, tol=1e-08, positive=True)\n', (21185, 21232), False, 'from sklearn import linear_model, datasets\n'), ((22030, 22060), 'numpy.linspace', 'np.linspace', (['(0.6)', '(1 - 0.01)', '(20)'], {}), '(0.6, 1 - 0.01, 20)\n', (22041, 22060), True, 'import numpy as np\n'), ((22524, 22583), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'method': '"""lasso"""', 'positive': '(True)'}), "(X, y, method='lasso', positive=True)\n", (22546, 22583), False, 'from sklearn import linear_model, datasets\n'), ((22650, 22736), 'sklearn.linear_model.Lasso', 'linear_model.Lasso', ([], {'fit_intercept': '(False)', 'normalize': '(True)', 'tol': '(1e-08)', 'positive': '(True)'}), '(fit_intercept=False, normalize=True, tol=1e-08, positive\n    =True)\n', (22668, 22736), False, 'from sklearn import linear_model, datasets\n'), ((23349, 23424), 'numpy.array', 'np.array', (['[-6.45006793, -3.51251449, -8.52445396, 6.12277822, -19.42109366]'], {}), '([-6.45006793, -3.51251449, -8.52445396, 6.12277822, -19.42109366])\n', (23357, 23424), True, 'import numpy as np\n'), ((23451, 23698), 'numpy.array', 'np.array', (['[[0.47299829, 0, 0, 0, 0], [0.08239882, 0.85784863, 0, 0, 0], [0.30114139, \n    -0.07501577, 0.80895216, 0, 0], [-0.01460346, -0.1015233, 0.0407278, \n    0.80338378, 0], [-0.69363927, 0.06754067, 0.18064514, -0.0803561, \n    0.40427291]]'], {}), '([[0.47299829, 0, 0, 0, 0], [0.08239882, 0.85784863, 0, 0, 0], [\n    0.30114139, -0.07501577, 0.80895216, 0, 0], [-0.01460346, -0.1015233, \n    0.0407278, 0.80338378, 0], [-0.69363927, 0.06754067, 0.18064514, -\n    0.0803561, 0.40427291]])\n', (23459, 23698), True, 'import numpy as np\n'), ((24314, 25017), 'numpy.array', 'np.array', (['[[0, 0, 0, 0, 0, -79.81036280949903, -83.52878873278283, -83.77765373919071,\n    -83.78415693288893, -84.03339059175666], [0, 0, 0, 0, -\n    0.476624256777266, 0, 0, 0, 0, 0.025219751009936], [0, -\n    3.577397088285891, -4.702795355871871, -7.016748621359461, -\n    7.614898471899412, -0.336938391359179, 0, 0, 0.001213370600853, \n    0.048162321585148], [0, 0, 0, 2.231558436628169, 2.723267514525966, \n    2.811549786389614, 2.813766976061531, 2.817462468949557, \n    2.817368178703816, 2.816221090636795], [0, 0, -1.218422599914637, -\n    3.457726183014808, -4.02130452206071, -45.827461592423745, -\n    47.776608869312305, -47.9115616107464, -47.914845922736234, -\n    48.03956233426572]]'], {}), '([[0, 0, 0, 0, 0, -79.81036280949903, -83.52878873278283, -\n    83.77765373919071, -83.78415693288893, -84.03339059175666], [0, 0, 0, 0,\n    -0.476624256777266, 0, 0, 0, 0, 0.025219751009936], [0, -\n    3.577397088285891, -4.702795355871871, -7.016748621359461, -\n    7.614898471899412, -0.336938391359179, 0, 0, 0.001213370600853, \n    0.048162321585148], [0, 0, 0, 2.231558436628169, 2.723267514525966, \n    2.811549786389614, 2.813766976061531, 2.817462468949557, \n    2.817368178703816, 2.816221090636795], [0, 0, -1.218422599914637, -\n    3.457726183014808, -4.02130452206071, -45.827461592423745, -\n    47.776608869312305, -47.9115616107464, -47.914845922736234, -\n    48.03956233426572]])\n', (24322, 25017), True, 'import numpy as np\n'), ((25283, 25352), 'sklearn.linear_model.LassoLars', 'linear_model.LassoLars', ([], {'alpha': '(0)', 'fit_intercept': '(False)', 'normalize': '(False)'}), '(alpha=0, fit_intercept=False, normalize=False)\n', (25305, 25352), False, 'from sklearn import linear_model, datasets\n'), ((25479, 25530), 'sklearn.utils.testing.assert_array_almost_equal', 'assert_array_almost_equal', (['r', 'skl_betas'], {'decimal': '(12)'}), '(r, skl_betas, decimal=12)\n', (25504, 25530), False, 'from sklearn.utils.testing import assert_array_almost_equal\n'), ((26388, 26661), 'numpy.array', 'np.array', (['[[0, 0, 0, 0, 0], [0, 0, 0, 8.371887668009453, 19.463768371044026], [0, 0, \n    0, 0, 9.901611055290553], [0, 7.495923132833733, 9.245133544334507, \n    17.389369207545062, 26.9716568156435], [0, 0, -1.569380717440311, -\n    5.924804108067312, -7.996385265061972]]'], {}), '([[0, 0, 0, 0, 0], [0, 0, 0, 8.371887668009453, 19.463768371044026],\n    [0, 0, 0, 0, 9.901611055290553], [0, 7.495923132833733, \n    9.245133544334507, 17.389369207545062, 26.9716568156435], [0, 0, -\n    1.569380717440311, -5.924804108067312, -7.996385265061972]])\n', (26396, 26661), True, 'import numpy as np\n'), ((26791, 26858), 'sklearn.linear_model.LassoLars', 'linear_model.LassoLars', ([], {'alpha': '(0)', 'fit_intercept': '(True)', 'normalize': '(True)'}), '(alpha=0, fit_intercept=True, normalize=True)\n', (26813, 26858), False, 'from sklearn import linear_model, datasets\n'), ((27238, 27291), 'sklearn.utils.testing.assert_array_almost_equal', 'assert_array_almost_equal', (['r2', 'skl_betas2'], {'decimal': '(12)'}), '(r2, skl_betas2, decimal=12)\n', (27263, 27291), False, 'from sklearn.utils.testing import assert_array_almost_equal\n'), ((27610, 27654), 'sklearn.linear_model.least_angle.LassoLarsIC', 'LassoLarsIC', ([], {'copy_X': 'copy_X', 'precompute': '(False)'}), '(copy_X=copy_X, precompute=False)\n', (27621, 27654), False, 'from sklearn.linear_model.least_angle import _lars_path_residues, LassoLarsIC\n'), ((27665, 27689), 'numpy.random.RandomState', 'np.random.RandomState', (['(0)'], {}), '(0)\n', (27686, 27689), True, 'import numpy as np\n'), ((28047, 28076), 'sklearn.linear_model.least_angle.LassoLarsIC', 'LassoLarsIC', ([], {'precompute': '(False)'}), '(precompute=False)\n', (28058, 28076), False, 'from sklearn.linear_model.least_angle import _lars_path_residues, LassoLarsIC\n'), ((28087, 28111), 'numpy.random.RandomState', 'np.random.RandomState', (['(0)'], {}), '(0)\n', (28108, 28111), True, 'import numpy as np\n'), ((1192, 1202), 'io.StringIO', 'StringIO', ([], {}), '()\n', (1200, 1202), False, 'from io import StringIO\n'), ((1231, 1285), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'method': '"""lar"""', 'verbose': '(10)'}), "(X, y, method='lar', verbose=10)\n", (1253, 1285), False, 'from sklearn import linear_model, datasets\n'), ((2067, 2083), 'numpy.dot', 'np.dot', (['X.T', 'res'], {}), '(X.T, res)\n', (2073, 2083), True, 'import numpy as np\n'), ((2510, 2533), 'sklearn.utils.testing.assert_allclose', 'assert_allclose', (['o1', 'o2'], {}), '(o1, o2)\n', (2525, 2533), False, 'from sklearn.utils.testing import assert_allclose\n'), ((2744, 2852), 'sklearn.linear_model.lars_path_gram', 'linear_model.lars_path_gram', ([], {'Xy': 'Xy', 'Gram': 'G', 'n_samples': 'n_samples', 'method': 'method', 'return_path': 'return_path'}), '(Xy=Xy, Gram=G, n_samples=n_samples, method=\n    method, return_path=return_path)\n', (2771, 2852), False, 'from sklearn import linear_model, datasets\n'), ((2882, 2958), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'Gram': 'G', 'method': 'method', 'return_path': 'return_path'}), '(X, y, Gram=G, method=method, return_path=return_path)\n', (2904, 2958), False, 'from sklearn import linear_model, datasets\n'), ((3426, 3469), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'method': 'method'}), '(X, y, method=method)\n', (3448, 3469), False, 'from sklearn import linear_model, datasets\n'), ((3491, 3549), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'Gram': 'G', 'Xy': 'Xy', 'method': 'method'}), '(X, y, Gram=G, Xy=Xy, method=method)\n', (3513, 3549), False, 'from sklearn import linear_model, datasets\n'), ((4155, 4190), 'numpy.linalg.lstsq', 'np.linalg.lstsq', (['X1', 'y'], {'rcond': 'rcond'}), '(X1, y, rcond=rcond)\n', (4170, 4190), True, 'import numpy as np\n'), ((4545, 4566), 'numpy.linalg.lstsq', 'np.linalg.lstsq', (['X', 'y'], {}), '(X, y)\n', (4560, 4566), True, 'import numpy as np\n'), ((5034, 5064), 'numpy.dot', 'np.dot', (['X', 'coef_path_[:, (-1)]'], {}), '(X, coef_path_[:, (-1)])\n', (5040, 5064), True, 'import numpy as np\n'), ((5551, 5576), 'numpy.zeros_like', 'np.zeros_like', (['coef_path_'], {}), '(coef_path_)\n', (5564, 5576), True, 'import numpy as np\n'), ((7412, 7468), 'sklearn.utils.testing.assert_array_almost_equal', 'assert_array_almost_equal', (['output_1', 'output_2'], {'decimal': '(8)'}), '(output_1, output_2, decimal=8)\n', (7437, 7468), False, 'from sklearn.utils.testing import assert_array_almost_equal\n'), ((8264, 8308), 'sklearn.linear_model.LassoLars', 'linear_model.LassoLars', (['(0.1)'], {'normalize': '(False)'}), '(0.1, normalize=False)\n', (8286, 8308), False, 'from sklearn import linear_model, datasets\n'), ((8530, 8581), 'sklearn.linear_model.Lasso', 'linear_model.Lasso', (['(0.1)'], {'tol': '(1e-06)', 'normalize': '(False)'}), '(0.1, tol=1e-06, normalize=False)\n', (8548, 8581), False, 'from sklearn import linear_model, datasets\n'), ((8767, 8812), 'sklearn.utils.testing.assert_less', 'assert_less', (['obj_lars', '(obj_cd * (1.0 + 1e-08))'], {}), '(obj_lars, obj_cd * (1.0 + 1e-08))\n', (8778, 8812), False, 'from sklearn.utils.testing import assert_less\n'), ((9256, 9287), 'scipy.linalg.norm', 'linalg.norm', (['(c - lasso_cd.coef_)'], {}), '(c - lasso_cd.coef_)\n', (9267, 9287), False, 'from scipy import linalg\n'), ((9296, 9320), 'sklearn.utils.testing.assert_less', 'assert_less', (['error', '(0.01)'], {}), '(error, 0.01)\n', (9307, 9320), False, 'from sklearn.utils.testing import assert_less\n'), ((9623, 9659), 'scipy.linalg.norm', 'linalg.norm', (['(clf1.coef_ - clf2.coef_)'], {}), '(clf1.coef_ - clf2.coef_)\n', (9634, 9659), False, 'from scipy import linalg\n'), ((9668, 9691), 'sklearn.utils.testing.assert_less', 'assert_less', (['err', '(0.001)'], {}), '(err, 0.001)\n', (9679, 9691), False, 'from sklearn.utils.testing import assert_less\n'), ((10093, 10124), 'scipy.linalg.norm', 'linalg.norm', (['(c - lasso_cd.coef_)'], {}), '(c - lasso_cd.coef_)\n', (10104, 10124), False, 'from scipy import linalg\n'), ((10133, 10157), 'sklearn.utils.testing.assert_less', 'assert_less', (['error', '(0.01)'], {}), '(error, 0.01)\n', (10144, 10157), False, 'from sklearn.utils.testing import assert_less\n'), ((10498, 10563), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'method': '"""lasso"""', 'alpha_min': 'alpha_min'}), "(X, y, method='lasso', alpha_min=alpha_min)\n", (10520, 10563), False, 'from sklearn import linear_model, datasets\n'), ((10638, 10688), 'sklearn.linear_model.Lasso', 'linear_model.Lasso', ([], {'fit_intercept': '(False)', 'tol': '(1e-08)'}), '(fit_intercept=False, tol=1e-08)\n', (10656, 10688), False, 'from sklearn import linear_model, datasets\n'), ((10767, 10816), 'scipy.linalg.norm', 'linalg.norm', (['(lasso_path[:, (-1)] - lasso_cd.coef_)'], {}), '(lasso_path[:, (-1)] - lasso_cd.coef_)\n', (10778, 10816), False, 'from scipy import linalg\n'), ((10823, 10847), 'sklearn.utils.testing.assert_less', 'assert_less', (['error', '(0.01)'], {}), '(error, 0.01)\n', (10834, 10847), False, 'from sklearn.utils.testing import assert_less\n'), ((10950, 11015), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (['X', 'y'], {'method': '"""lasso"""', 'alpha_min': 'alpha_min'}), "(X, y, method='lasso', alpha_min=alpha_min)\n", (10972, 11015), False, 'from sklearn import linear_model, datasets\n'), ((11090, 11155), 'sklearn.linear_model.Lasso', 'linear_model.Lasso', ([], {'fit_intercept': '(True)', 'normalize': '(True)', 'tol': '(1e-08)'}), '(fit_intercept=True, normalize=True, tol=1e-08)\n', (11108, 11155), False, 'from sklearn import linear_model, datasets\n'), ((11272, 11321), 'scipy.linalg.norm', 'linalg.norm', (['(lasso_path[:, (-1)] - lasso_cd.coef_)'], {}), '(lasso_path[:, (-1)] - lasso_cd.coef_)\n', (11283, 11321), False, 'from scipy import linalg\n'), ((11328, 11352), 'sklearn.utils.testing.assert_less', 'assert_less', (['error', '(0.01)'], {}), '(error, 0.01)\n', (11339, 11352), False, 'from sklearn.utils.testing import assert_less\n'), ((14260, 14272), 'numpy.arange', 'np.arange', (['n'], {}), '(n)\n', (14269, 14272), True, 'import numpy as np\n'), ((14292, 14314), 'numpy.isfinite', 'np.isfinite', (['clf.coef_'], {}), '(clf.coef_)\n', (14303, 14314), True, 'import numpy as np\n'), ((14753, 14775), 'numpy.vstack', 'np.vstack', (['[y, y ** 2]'], {}), '([y, y ** 2])\n', (14762, 14775), True, 'import numpy as np\n'), ((14832, 14856), 'sklearn.linear_model.LassoLars', 'linear_model.LassoLars', ([], {}), '()\n', (14854, 14856), False, 'from sklearn import linear_model, datasets\n'), ((14866, 14885), 'sklearn.linear_model.Lars', 'linear_model.Lars', ([], {}), '()\n', (14883, 14885), False, 'from sklearn import linear_model, datasets\n'), ((14933, 14976), 'sklearn.linear_model.LassoLars', 'linear_model.LassoLars', ([], {'fit_intercept': '(False)'}), '(fit_intercept=False)\n', (14955, 14976), False, 'from sklearn import linear_model, datasets\n'), ((14986, 15024), 'sklearn.linear_model.Lars', 'linear_model.Lars', ([], {'fit_intercept': '(False)'}), '(fit_intercept=False)\n', (15003, 15024), False, 'from sklearn import linear_model, datasets\n'), ((16281, 16336), 'numpy.testing.assert_array_less', 'np.testing.assert_array_less', (['old_alpha', 'lars_cv.alpha_'], {}), '(old_alpha, lars_cv.alpha_)\n', (16309, 16336), True, 'import numpy as np\n'), ((16516, 16552), 'warnings.catch_warnings', 'warnings.catch_warnings', ([], {'record': '(True)'}), '(record=True)\n', (16539, 16552), False, 'import warnings\n'), ((16573, 16598), 'numpy.random.RandomState', 'np.random.RandomState', (['(42)'], {}), '(42)\n', (16594, 16598), True, 'import numpy as np\n'), ((16727, 16763), 'sklearn.linear_model.LassoLarsCV', 'linear_model.LassoLarsCV', ([], {'max_iter': '(5)'}), '(max_iter=5)\n', (16751, 16763), False, 'from sklearn import linear_model, datasets\n'), ((17282, 17306), 'numpy.where', 'np.where', (['lars_bic.coef_'], {}), '(lars_bic.coef_)\n', (17290, 17306), True, 'import numpy as np\n'), ((17328, 17352), 'numpy.where', 'np.where', (['lars_aic.coef_'], {}), '(lars_aic.coef_)\n', (17336, 17352), True, 'import numpy as np\n'), ((17477, 17496), 'numpy.max', 'np.max', (['nonzero_bic'], {}), '(nonzero_bic)\n', (17483, 17496), True, 'import numpy as np\n'), ((17973, 17998), 'sklearn.utils.testing.TempMemmap', 'TempMemmap', (['splitted_data'], {}), '(splitted_data)\n', (17983, 17998), False, 'from sklearn.utils.testing import TempMemmap\n'), ((18105, 18170), 'sklearn.linear_model.least_angle._lars_path_residues', '_lars_path_residues', (['X_train', 'y_train', 'X_test', 'y_test'], {'copy': '(False)'}), '(X_train, y_train, X_test, y_test, copy=False)\n', (18124, 18170), False, 'from sklearn.linear_model.least_angle import _lars_path_residues, LassoLarsIC\n'), ((18844, 18892), 'pytest.warns', 'pytest.warns', (['DeprecationWarning'], {'match': '"""broken"""'}), "(DeprecationWarning, match='broken')\n", (18856, 18892), False, 'import pytest\n'), ((18902, 19014), 'sklearn.linear_model.lars_path', 'linear_model.lars_path', (["diabetes['data']", "diabetes['target']"], {'return_path': '(True)', 'method': '"""lar"""', 'positive': '(True)'}), "(diabetes['data'], diabetes['target'], return_path=\n    True, method='lar', positive=True)\n", (18924, 19014), False, 'from sklearn import linear_model, datasets\n'), ((21385, 21416), 'scipy.linalg.norm', 'linalg.norm', (['(c - lasso_cd.coef_)'], {}), '(c - lasso_cd.coef_)\n', (21396, 21416), False, 'from scipy import linalg\n'), ((21425, 21449), 'sklearn.utils.testing.assert_less', 'assert_less', (['error', '(0.01)'], {}), '(error, 0.01)\n', (21436, 21449), False, 'from sklearn.utils.testing import assert_less\n'), ((22383, 22419), 'scipy.linalg.norm', 'linalg.norm', (['(clf1.coef_ - clf2.coef_)'], {}), '(clf1.coef_ - clf2.coef_)\n', (22394, 22419), False, 'from scipy import linalg\n'), ((22428, 22451), 'sklearn.utils.testing.assert_less', 'assert_less', (['err', '(0.001)'], {}), '(err, 0.001)\n', (22439, 22451), False, 'from sklearn.utils.testing import assert_less\n'), ((22913, 22944), 'scipy.linalg.norm', 'linalg.norm', (['(c - lasso_cd.coef_)'], {}), '(c - lasso_cd.coef_)\n', (22924, 22944), False, 'from scipy import linalg\n'), ((22953, 22977), 'sklearn.utils.testing.assert_less', 'assert_less', (['error', '(0.01)'], {}), '(error, 0.01)\n', (22964, 22977), False, 'from sklearn.utils.testing import assert_less\n'), ((27128, 27146), 'numpy.mean', 'np.mean', (['X'], {'axis': '(0)'}), '(X, axis=0)\n', (27135, 27146), True, 'import numpy as np\n'), ((27167, 27192), 'numpy.sum', 'np.sum', (['(temp ** 2)'], {'axis': '(0)'}), '(temp ** 2, axis=0)\n', (27173, 27192), True, 'import numpy as np\n'), ((27809, 27834), 'numpy.array_equal', 'np.array_equal', (['X', 'X_copy'], {}), '(X, X_copy)\n', (27823, 27834), True, 'import numpy as np\n'), ((28246, 28271), 'numpy.array_equal', 'np.array_equal', (['X', 'X_copy'], {}), '(X, X_copy)\n', (28260, 28271), True, 'import numpy as np\n'), ((1439, 1455), 'numpy.dot', 'np.dot', (['X.T', 'res'], {}), '(X.T, res)\n', (1445, 1455), True, 'import numpy as np\n'), ((2036, 2052), 'numpy.dot', 'np.dot', (['X', 'coef_'], {}), '(X, coef_)\n', (2042, 2052), True, 'import numpy as np\n'), ((3660, 3700), 'sklearn.utils.testing.assert_array_almost_equal', 'assert_array_almost_equal', (['expected', 'got'], {}), '(expected, got)\n', (3685, 3700), False, 'from sklearn.utils.testing import assert_array_almost_equal\n'), ((4091, 4119), 'distutils.version.LooseVersion', 'LooseVersion', (['np.__version__'], {}), '(np.__version__)\n', (4103, 4119), False, 'from distutils.version import LooseVersion\n'), ((7229, 7253), 'sklearn.utils.testing.ignore_warnings', 'ignore_warnings', (['clf.fit'], {}), '(clf.fit)\n', (7244, 7253), False, 'from sklearn.utils.testing import ignore_warnings\n'), ((11735, 11757), 'numpy.diff', 'np.diff', (['lasso.alphas_'], {}), '(lasso.alphas_)\n', (11742, 11757), True, 'import numpy as np\n'), ((14144, 14163), 'numpy.arange', 'np.arange', (['(1)', '(n + 1)'], {}), '(1, n + 1)\n', (14153, 14163), True, 'import numpy as np\n'), ((14205, 14243), 'sklearn.linear_model.Lars', 'linear_model.Lars', ([], {'fit_intercept': '(False)'}), '(fit_intercept=False)\n', (14222, 14243), False, 'from sklearn import linear_model, datasets\n'), ((15412, 15467), 'sklearn.utils.testing.assert_array_almost_equal', 'assert_array_almost_equal', (['alphas[k]', 'estimator.alphas_'], {}), '(alphas[k], estimator.alphas_)\n', (15437, 15467), False, 'from sklearn.utils.testing import assert_array_almost_equal\n'), ((15480, 15535), 'sklearn.utils.testing.assert_array_almost_equal', 'assert_array_almost_equal', (['active[k]', 'estimator.active_'], {}), '(active[k], estimator.active_)\n', (15505, 15535), False, 'from sklearn.utils.testing import assert_array_almost_equal\n'), ((15548, 15599), 'sklearn.utils.testing.assert_array_almost_equal', 'assert_array_almost_equal', (['coef[k]', 'estimator.coef_'], {}), '(coef[k], estimator.coef_)\n', (15573, 15599), False, 'from sklearn.utils.testing import assert_array_almost_equal\n'), ((15612, 15668), 'sklearn.utils.testing.assert_array_almost_equal', 'assert_array_almost_equal', (['path[k]', 'estimator.coef_path_'], {}), '(path[k], estimator.coef_path_)\n', (15637, 15668), False, 'from sklearn.utils.testing import assert_array_almost_equal\n'), ((15681, 15730), 'sklearn.utils.testing.assert_array_almost_equal', 'assert_array_almost_equal', (['Y_pred[:, (k)]', 'y_pred'], {}), '(Y_pred[:, (k)], y_pred)\n', (15706, 15730), False, 'from sklearn.utils.testing import assert_array_almost_equal\n'), ((1404, 1420), 'numpy.dot', 'np.dot', (['X', 'coef_'], {}), '(X, coef_)\n', (1410, 1420), True, 'import numpy as np\n'), ((4992, 5012), 'numpy.isnan', 'np.isnan', (['coef_path_'], {}), '(coef_path_)\n', (5000, 5012), True, 'import numpy as np\n'), ((8478, 8504), 'scipy.linalg.norm', 'linalg.norm', (['coef_lars_', '(1)'], {}), '(coef_lars_, 1)\n', (8489, 8504), False, 'from scipy import linalg\n'), ((8733, 8757), 'scipy.linalg.norm', 'linalg.norm', (['coef_cd_', '(1)'], {}), '(coef_cd_, 1)\n', (8744, 8757), False, 'from scipy import linalg\n'), ((9428, 9480), 'sklearn.linear_model.LassoLars', 'linear_model.LassoLars', ([], {'alpha': 'alpha', 'normalize': '(False)'}), '(alpha=alpha, normalize=False)\n', (9450, 9480), False, 'from sklearn import linear_model, datasets\n'), ((9506, 9565), 'sklearn.linear_model.Lasso', 'linear_model.Lasso', ([], {'alpha': 'alpha', 'tol': '(1e-08)', 'normalize': '(False)'}), '(alpha=alpha, tol=1e-08, normalize=False)\n', (9524, 9565), False, 'from sklearn import linear_model, datasets\n'), ((13551, 13571), 'scipy.linalg.norm', 'linalg.norm', (['coef', '(1)'], {}), '(coef, 1)\n', (13562, 13571), False, 'from scipy import linalg\n'), ((14166, 14178), 'numpy.arange', 'np.arange', (['n'], {}), '(n)\n', (14175, 14178), True, 'import numpy as np\n'), ((22078, 22170), 'sklearn.linear_model.LassoLars', 'linear_model.LassoLars', ([], {'fit_intercept': '(False)', 'alpha': 'alpha', 'normalize': '(False)', 'positive': '(True)'}), '(fit_intercept=False, alpha=alpha, normalize=False,\n    positive=True)\n', (22100, 22170), False, 'from sklearn import linear_model, datasets\n'), ((22230, 22330), 'sklearn.linear_model.Lasso', 'linear_model.Lasso', ([], {'fit_intercept': '(False)', 'alpha': 'alpha', 'tol': '(1e-08)', 'normalize': '(False)', 'positive': '(True)'}), '(fit_intercept=False, alpha=alpha, tol=1e-08, normalize=\n    False, positive=True)\n', (22248, 22330), False, 'from sklearn import linear_model, datasets\n'), ((8423, 8444), 'numpy.dot', 'np.dot', (['X', 'coef_lars_'], {}), '(X, coef_lars_)\n', (8429, 8444), True, 'import numpy as np\n'), ((8682, 8701), 'numpy.dot', 'np.dot', (['X', 'coef_cd_'], {}), '(X, coef_cd_)\n', (8688, 8701), True, 'import numpy as np\n'), ((13503, 13518), 'numpy.dot', 'np.dot', (['X', 'coef'], {}), '(X, coef)\n', (13509, 13518), True, 'import numpy as np\n')]