This readme is intended to help those contributing to or editing the book, not those trying to follow it. To read or use the book, head to the coding for economists website. You can use the book interactively via the following options, all available via the link above:
- download pages to your computer as jupyter notebooks
- run pages in Google Colab through your browser
- run pages in Binder through your browser
These instructions are only for developers working on the book.
Install the environment using
conda env create -f environment.yml
on the command line. After installing the environment, activate using conda activate codeforecon
, and use
python3.8 -m ipykernel install --user --name=codeforecon
to install a new named ipykernel. To ensure that Jupyter notebooks are running the correct kernel, open them in Jupyter notebook server and change the kernel there to 'codeforecon' and save it.
To build the book using Jupyter books use
jupyter-book build .
Once this command is run, you should be able to look at the HTML files for the book locally on your computer.
See here for how to upload revised HTML files, but the key command is
ghp-import -n -p -f _build/html
To perform the pre-commit checks, use
pre-commit run --all-files
Pre-commit is currently configured to:
- check for large added files
- strip outputs from notebooks
- apply the black code formatter to .py and .ipnb scripts
If black-nb finds a pre-commit error that is difficult to diagnose, a tip is to convert it to a regular script to find the problem, using, for example,
jupytext --to py data-intro.ipynb