def copy_index(tmpdir):
    # Put the code being checked-in into the temp dir
    subprocess.check_call(['git', 'checkout-index', '-a', '-f', '--prefix=%s/'
                           % tmpdir])

    # Go to each recursive submodule and use a 'git archive' tarpipe to copy
    # the correct ref into the temporary directory
    output = check_output(['git', 'submodule', 'status', '--recursive',
                           '--cached'])
    for line in output.splitlines():
        ref, path, _ = line.split()
        ref = ref.strip('+')
        with pushd(path):
            archive = subprocess.Popen(['git', 'archive', '--format=tar', ref],
                                       stdout=subprocess.PIPE)
            untar_cmd = ['tar', '-x', '-C', '%s/%s/' % (tmpdir, path)]
            untar = subprocess.Popen(untar_cmd, stdin=archive.stdout,
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.STDOUT)
            out = untar.communicate()[0]
            if untar.returncode != 0:
                raise subprocess.CalledProcessError(untar.returncode,
                                                    untar_cmd, out)
Fit Ridge regression model
dataset/ETHPy150Open mathcamp/pypicloud/git_hooks/hook.py/copy_index--crossover with--dataset/ETHPy150Open scikit-learn/scikit-learn/sklearn/linear_model/ridge.py/Ridge.fit