Пример #1
0
#!/usr/bin/env python
"""Run problem set.

This script allows to run the handouts. One can either run all problem sets at once or just a
single one. It is enough to provide a substring for the name.

Examples
--------

>> run-handout             Run all handouts set.

>> run-handout -n 01      Run handout 01-causal-graphs.
"""
import os

from auxiliary import parse_arguments
from auxiliary import compile_single
from auxiliary import HANDOUTS_ROOT

if __name__ == "__main__":

    request = parse_arguments("Create handout set")

    os.chdir(HANDOUTS_ROOT)

    for dirname in request:
        os.chdir(dirname)
        if os.path.exists("sources"):
            compile_single("sources", "handout")
        os.chdir("../")
Пример #2
0
#!/usr/bin/env python
"""Run problem set.

This script allows to run the problem set. One can either run all problem sets at once or just a
single one. It is enough to provide a substring for the name.

Examples
--------

>> run-problem             Run all problem set.

>> run-problem -n 01      Run slide 01-potential-outcome-model.
"""
import os

from auxiliary import PROBLEM_SETS_ROOT
from auxiliary import parse_arguments
from auxiliary import compile_single

if __name__ == "__main__":

    request = parse_arguments("Create problem set")

    os.chdir(PROBLEM_SETS_ROOT)

    for dirname in request:
        os.chdir(dirname)
        if os.path.exists("sources"):
            compile_single("sources", "problem-set")
        os.chdir("../")
Пример #3
0
#!/usr/bin/env python
"""Run specials.

This script allows to run the special notebooks. One can either run all notebooks at once or just a
single lecture. It is enough to provide a substring for the name.

Examples
--------

>> run-special             Run all specials.

>> run-special -n 01      Run special nonstandard-standard_errors.
"""
import glob
import os

from auxiliary import parse_arguments
from auxiliary import HANDOUTS_ROOT
from auxiliary import run_notebook

if __name__ == "__main__":

    request = parse_arguments("Execute handouts")
    os.chdir(HANDOUTS_ROOT)

    for fname in glob.glob("*.ipynb"):
        print(f"\n {os.getcwd().split('/')[-1]}\n")
        run_notebook(fname)
Пример #4
0
This script allows to run the lecture notebooks. One can either run all notebooks at once or just a
single lecture. It is enough to provide a substring for the name.

Examples
--------
>> run-lecture             Run all lectures.

>> run-lecture -n intr     Run lecture 01-introduction.
"""
import glob
import os

from auxiliary import LECTURES_ROOT
from auxiliary import parse_arguments
from auxiliary import run_notebook


if __name__ == "__main__":

    request = parse_arguments("Execute notebook")
    os.chdir(LECTURES_ROOT)

    for dirname in request:

        os.chdir(dirname)
        for fname in glob.glob("*.ipynb"):
            print(f"\n {os.getcwd().split('/')[-1]}\n")  # noqa
            run_notebook(fname)
        os.chdir("../")
Пример #5
0
#!/usr/bin/env python
"""This module compiles the lecture notes."""
import subprocess
import shutil
import os

from auxiliary import parse_arguments
from auxiliary import LECTURES_ROOT


def compile_single(is_update):
    """Compile a single lecture."""
    for task in ['pdflatex', 'bibtex', 'pdflatex', 'pdflatex']:
        subprocess.check_call(task + ' main', shell=True)
    shutil.move("main.pdf", "slides.pdf")


if __name__ == '__main__':

    request = parse_arguments('Create lecture slides')

    os.chdir(LECTURES_ROOT)

    for dirname in request:
        os.chdir(dirname)
        compile_single('slides')
        os.chdir('../')
Пример #6
0
>> run-special             Run all specials.

>> run-special -n 01      Run special nonstandard-standard_errors.
"""
import subprocess as sp
import glob
import os

from auxiliary import parse_arguments
from auxiliary import SPECIALS_ROOT


def run_notebook(notebook):
    cmd = " jupyter nbconvert --execute {}  --ExecutePreprocessor.timeout=-1".format(
        notebook)
    sp.check_call(cmd, shell=True)


if __name__ == "__main__":

    request = parse_arguments("Execute special")
    os.chdir(SPECIALS_ROOT)

    for dirname in request:
        os.chdir(dirname)
        for fname in glob.glob("*.ipynb"):
            print(f"\n {os.getcwd().split('/')[-1]}\n")
            run_notebook(fname)
        os.chdir("../")
Пример #7
0
#!/usr/bin/env python
"""Run slide.

This script allows to run the lecture slides. One can either run all slides at once or just a
single lecture. It is enough to provide a substring for the name.

Examples
--------

>> run-slide             Run all slides.

>> run-slide -n 01_      Run slide 01_introduction.
"""
import os

from auxiliary import parse_arguments
from auxiliary import compile_single
from auxiliary import LECTURES_ROOT

if __name__ == "__main__":

    request = parse_arguments("Create lecture slides")

    os.chdir(LECTURES_ROOT)

    for dirname in request:
        os.chdir(dirname)
        if os.path.exists("slides"):
            compile_single("slides", "slides")
        os.chdir("../")
Пример #8
0
#!/usr/bin/env python
"""This module executes all notebooks. It serves the main purpose to ensure that all can be
executed and work proper independently."""
import subprocess as sp
import glob
import os

from auxiliary import parse_arguments
from auxiliary import LECTURES_ROOT


def run_notebook(notebook):
    cmd = ' jupyter nbconvert --execute {}  --ExecutePreprocessor.timeout=-1'.format(
        notebook)
    sp.check_call(cmd, shell=True)


if __name__ == '__main__':

    request = parse_arguments('Execute notebook')
    os.chdir(LECTURES_ROOT)

    for dirname in request:
        os.chdir(dirname)
        for fname in glob.glob('*.ipynb'):
            run_notebook(fname)
        os.chdir('../')