Skip to content

Commit dcce12f

Browse files
committed
Merge branch 'update-olg' of https://github.com/QuantEcon/lecture-python-intro into update-olg
2 parents 391a9e8 + 649ef8c commit dcce12f

File tree

12 files changed

+1623
-64
lines changed

12 files changed

+1623
-64
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Build HTML [using jupyter-book]
2-
on: [push]
2+
on: [pull_request]
33
jobs:
4-
tests:
4+
preview:
55
runs-on: ubuntu-latest
66
steps:
77
- name: Checkout
@@ -51,12 +51,12 @@ jobs:
5151
# jb build lectures --builder pdflatex --path-output ./ -n --keep-going
5252
# mkdir -p _build/html/_pdf
5353
# cp -u _build/latex/*.pdf _build/html/_pdf
54-
# - name: Build Download Notebooks (sphinx-tojupyter)
55-
# shell: bash -l {0}
56-
# run: |
57-
# jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter
58-
# mkdir -p _build/html/_notebooks
59-
# cp -u _build/jupyter/*.ipynb _build/html/_notebooks
54+
- name: Build Download Notebooks (sphinx-tojupyter)
55+
shell: bash -l {0}
56+
run: |
57+
jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter
58+
mkdir -p _build/html/_notebooks
59+
cp -u _build/jupyter/*.ipynb _build/html/_notebooks
6060
# Build HTML (Website)
6161
# BUG: rm .doctress to remove `sphinx` rendering issues for ipywidget mimetypes
6262
# and clear the sphinx cache for building final HTML documents.

.github/workflows/publish.yml

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ jobs:
5555
# run: |
5656
# mkdir -p _build/html/_pdf
5757
# cp -u _build/latex/*.pdf _build/html/_pdf
58-
# - name: Build Download Notebooks (sphinx-tojupyter)
59-
# shell: bash -l {0}
60-
# run: |
61-
# jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter
62-
# - name: Copy Download Notebooks for GH-PAGES
63-
# shell: bash -l {0}
64-
# run: |
65-
# mkdir -p _build/html/_notebooks
66-
# cp -u _build/jupyter/*.ipynb _build/html/_notebooks
58+
- name: Build Download Notebooks (sphinx-tojupyter)
59+
shell: bash -l {0}
60+
run: |
61+
jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter
62+
- name: Copy Download Notebooks for GH-PAGES
63+
shell: bash -l {0}
64+
run: |
65+
mkdir -p _build/html/_notebooks
66+
cp -u _build/jupyter/*.ipynb _build/html/_notebooks
6767
# Build HTML (Website)
6868
# BUG: rm .doctress to remove `sphinx` rendering issues for ipywidget mimetypes
6969
# and clear the sphinx cache for building final HTML documents.
@@ -82,32 +82,33 @@ jobs:
8282
env:
8383
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
8484
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
85-
# - name: Deploy website to gh-pages
86-
# uses: peaceiris/actions-gh-pages@v3
87-
# with:
88-
# github_token: ${{ secrets.GITHUB_TOKEN }}
89-
# publish_dir: _build/html/
85+
- name: Deploy website to gh-pages
86+
uses: peaceiris/actions-gh-pages@v3
87+
with:
88+
github_token: ${{ secrets.GITHUB_TOKEN }}
89+
publish_dir: _build/html/
9090
# cname: intro.quantecon.org
9191
- name: Upload "_build" folder (cache)
9292
uses: actions/upload-artifact@v2
9393
with:
9494
name: build-publish
9595
path: _build
96-
# - name: Prepare lecture-python-intro.notebooks sync
97-
# shell: bash -l {0}
98-
# run: |
99-
# mkdir -p _build/lecture-python-intro.notebooks
100-
# cp -a _notebook_repo/. _build/lecture-python-intro.notebooks
101-
# cp _build/jupyter/*.ipynb _build/lecture-python-intro.notebooks
102-
# ls -a _build/lecture-python-intro.notebooks
103-
# - name: Commit latest notebooks to lecture-python-intro.notebooks
104-
# uses: cpina/github-action-push-to-another-repository@master
105-
# env:
106-
# API_TOKEN_GITHUB: ${{ secrets.QUANTECON_SERVICES_PAT }}
107-
# with:
108-
# source-directory: '_build/lecture-python-intro.notebooks/'
109-
# destination-repository-username: 'QuantEcon'
110-
# destination-repository-name: 'lecture-python-intro.notebooks'
111-
# commit-message: 'auto publishing updates to notebooks'
112-
# destination-github-username: 'quantecon-services'
113-
# user-email: services@quantecon.org
96+
# Sync notebooks
97+
- name: Prepare lecture-python-intro.notebooks sync
98+
shell: bash -l {0}
99+
run: |
100+
mkdir -p _build/lecture-python-intro.notebooks
101+
cp -a _notebook_repo/. _build/lecture-python-intro.notebooks
102+
cp _build/jupyter/*.ipynb _build/lecture-python-intro.notebooks
103+
ls -a _build/lecture-python-intro.notebooks
104+
- name: Commit latest notebooks to lecture-python-intro.notebooks
105+
uses: cpina/github-action-push-to-another-repository@main
106+
env:
107+
API_TOKEN_GITHUB: ${{ secrets.QUANTECON_SERVICES_PAT }}
108+
with:
109+
source-directory: '_build/lecture-python-intro.notebooks/'
110+
destination-repository-username: 'QuantEcon'
111+
destination-repository-name: 'lecture-python-intro.notebooks'
112+
commit-message: 'auto publishing updates to notebooks'
113+
destination-github-username: 'quantecon-services'
114+
user-email: services@quantecon.org

_notebook_repo/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# lecture-python-intro.notebooks
2+
3+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/QuantEcon/lecture-python-intro.notebooks/master)
4+
5+
<!-- Notebooks for https://python-intro.quantecon.org -->
6+
7+
**Note:** This README should be edited [here](https://github.com/quantecon/lecture-python-intro/_notebook_repo)

_notebook_repo/environment.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: lecture-python-intro
2+
channels:
3+
- default
4+
dependencies:
5+
- python=3.10
6+
- anaconda=2023.03
7+

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies:
88
- pip:
99
- jupyter-book==0.15.1
1010
- docutils==0.17.1
11-
- quantecon-book-theme==0.4.1
11+
- quantecon-book-theme==0.4.2
1212
- sphinx-tojupyter==0.3.0
1313
- sphinxext-rediraffe==0.2.7
1414
- sphinx-exercise==0.4.1

lectures/_config.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ parse:
1717
- substitution
1818
- tasklist
1919

20+
only_build_toc_files: true
2021
execute:
2122
execute_notebooks: "cache"
2223
timeout: 600 # 10 minutes
23-
# run_in_temp: true
24+
exclude_patterns:
25+
- '_static/*'
2426

2527
html:
2628
baseurl: https://intro.quantecon.org/
@@ -33,21 +35,21 @@ latex:
3335
targetname: quantecon-python-intro.tex
3436

3537
sphinx:
36-
extra_extensions: [sphinx_multitoc_numbering, sphinxext.rediraffe, sphinx_exercise, sphinx_togglebutton, sphinx_proof] # sphinx_tojupyter
38+
extra_extensions: [sphinx_multitoc_numbering, sphinxext.rediraffe, sphinx_exercise, sphinx_togglebutton, sphinx_proof, sphinx_tojupyter]
3739
config:
3840
html_favicon: _static/lectures-favicon.ico
3941
html_theme: quantecon_book_theme
4042
html_static_path: ['_static']
4143
html_theme_options:
42-
# header_organisation_url: https://quantecon.org
43-
# header_organisation: QuantEcon
44+
header_organisation_url: https://quantecon.org
45+
header_organisation: QuantEcon
4446
repository_url: https://github.com/QuantEcon/lecture-python-intro
45-
# nb_repository_url: https://github.com/QuantEcon/lecture-python-intro.notebooks
46-
# twitter: quantecon
47-
# twitter_logo_url: https://assets.quantecon.org/img/qe-twitter-logo.png
48-
# og_logo_url: https://assets.quantecon.org/img/qe-og-logo.png
49-
# description: This website presents a set of lectures on python programming for economics, designed and written by Thomas J. Sargent and John Stachurski.
50-
# keywords: Python, QuantEcon, Quantitative Economics, Economics, Sloan, Alfred P. Sloan Foundation, Tom J. Sargent, John Stachurski
47+
nb_repository_url: https://github.com/QuantEcon/lecture-python-intro.notebooks
48+
twitter: quantecon
49+
twitter_logo_url: https://assets.quantecon.org/img/qe-twitter-logo.png
50+
og_logo_url: https://assets.quantecon.org/img/qe-og-logo.png
51+
description: This website presents introductory lectures on computational economics, designed and written by Thomas J. Sargent and John Stachurski.
52+
keywords: Python, QuantEcon, Quantitative Economics, Economics, Sloan, Alfred P. Sloan Foundation, Tom J. Sargent, John Stachurski
5153
# analytics:
5254
# google_analytics_id: UA-54984338-9
5355
launch_buttons:

lectures/cobweb.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ where $a, b$ are nonnegative constants and $p_t$ is the spot (i.e, current marke
106106

107107
($D(p_t)$ is the quantity demanded in some fixed unit, such as thousands of tons.)
108108

109-
Because the crop of soy beans for time $t$ is planted at $t-1$, supply of soy beans at time $t$ depends on *expected* prices at time $t$, which we denote $p^e_t$.
109+
Because the crop of soy beans for time $t$ is planted at $t-1$, supply of soy beans at time $t$ depends on *expected* prices at time $t$, which we denote $p^e_{t-1}$.
110110

111111
We suppose that supply is nonlinear in expected prices, and takes the form
112112

113113
$$
114-
S(p^e_t) = \tanh(\lambda(p^e_t - c)) + d
114+
S(p^e_{t-1}) = \tanh(\lambda(p^e_{t-1} - c)) + d
115115
$$
116116

117117
where $\lambda$ is a positive constant and $c, d \geq 0$.
@@ -160,13 +160,13 @@ plt.show()
160160
Market equilibrium requires that supply equals demand, or
161161

162162
$$
163-
a - b p_t = S(p^e_t)
163+
a - b p_t = S(p^e_{t-1})
164164
$$
165165

166166
Rewriting in terms of $p_t$ gives
167167

168168
$$
169-
p_t = - \frac{1}{b} [S(p^e_t) - a]
169+
p_t = - \frac{1}{b} [S(p^e_{t-1}) - a]
170170
$$
171171

172172
Finally, to complete the model, we need to describe how price expectations are formed.
@@ -177,7 +177,7 @@ In particular, we suppose that
177177

178178
```{math}
179179
:label: p_et
180-
p^e_t = f(p_{t-1}, p_{t-2})
180+
p^e_{t-1} = f(p_{t-1}, p_{t-2})
181181
```
182182

183183
where $f$ is some function.
@@ -204,7 +204,7 @@ Let's start with naive expectations, which refers to the case where producers ex
204204

205205
In other words,
206206

207-
$$ p_t^e = p_{t-1} $$
207+
$$ p_{t-1}^e = p_{t-1} $$
208208

209209
Using {eq}`price_t`, we then have
210210

@@ -276,7 +276,7 @@ def plot45(model, pmin, pmax, p0, num_arrows=5):
276276
alpha=0.6, head_length=hl)
277277
278278
ax.plot(pgrid, g(model, pgrid), 'b-',
279-
lw=2, alpha=0.6, label='p')
279+
lw=2, alpha=0.6, label='g')
280280
ax.plot(pgrid, pgrid, lw=1, alpha=0.7, label='45')
281281
282282
x = p0
@@ -408,15 +408,15 @@ That is,
408408

409409
```{math}
410410
:label: pe_adaptive
411-
p_t^e = \alpha p_{t-1} + (1-\alpha) p^e_{t-1}
411+
p_{t-1}^e = \alpha p_{t-1} + (1-\alpha) p^e_{t-2}
412412
\qquad (0 \leq \alpha \leq 1)
413413
```
414414

415415
Another way to write this is
416416

417417
```{math}
418418
:label: pe_adaptive_2
419-
p_t^e = p^e_{t-1} + \alpha (p_{t-1} - p_{t-1}^e)
419+
p_{t-1}^e = p^e_{t-2} + \alpha (p_{t-1} - p_{t-2}^e)
420420
```
421421

422422
This equation helps to show that expectations shift
@@ -427,7 +427,7 @@ This equation helps to show that expectations shift
427427
Using {eq}`pe_adaptive`, we obtain the dynamics
428428

429429
$$
430-
p_t = - \frac{1}{b} [ S(\alpha p_{t-1} + (1-\alpha) p^e_{t-1}) - a]
430+
p_t = - \frac{1}{b} [ S(\alpha p_{t-1} + (1-\alpha) p^e_{t-2}) - a]
431431
$$
432432

433433

@@ -547,7 +547,7 @@ That is,
547547

548548
```{math}
549549
:label: pe_blae
550-
p_t^e = \alpha p_{t-1} + (1-\alpha) p_{t-2}
550+
p_{t-1}^e = \alpha p_{t-1} + (1-\alpha) p_{t-2}
551551
```
552552

553553

@@ -610,3 +610,4 @@ ts_plot_price_blae(m,
610610
```{code-cell} ipython3
611611
612612
```
613+

lectures/eigen_II.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ kernelspec:
2020
:depth: 2
2121
```
2222

23+
In addition to what's in Anaconda, this lecture will need the following libraries:
24+
25+
```{code-cell} ipython
26+
---
27+
tags: [hide-output]
28+
---
29+
!pip install graphviz
30+
```
31+
32+
```{admonition} graphviz
33+
:class: warning
34+
If you are running this lecture locally it requires [graphviz](https://www.graphviz.org)
35+
to be installed on your computer. Installation instructions for graphviz can be found
36+
[here](https://www.graphviz.org/download/)
37+
```
38+
2339
In this lecture we will begin with the basic properties of nonnegative matrices.
2440

2541
Then we will explore the Perron-Frobenius Theorem and the Neumann Series Lemma, and connect them to applications in Markov chains and networks.

lectures/lake_model.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,22 @@ kernelspec:
1313

1414
# A Lake Model of Employment
1515

16-
\
16+
In addition to what's in Anaconda, this lecture will need the following libraries:
17+
18+
```{code-cell} ipython
19+
---
20+
tags: [hide-output]
21+
---
22+
!pip install graphviz
23+
```
24+
25+
```{admonition} graphviz
26+
:class: warning
27+
If you are running this lecture locally it requires [graphviz](https://www.graphviz.org)
28+
to be installed on your computer. Installation instructions for graphviz can be found
29+
[here](https://www.graphviz.org/download/)
30+
```
31+
1732
This lecture studies a model of employment and unemployment flows in a large
1833
population.
1934

lectures/markov_chains_I.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ In addition to what's in Anaconda, this lecture will need the following librarie
2424
!pip install graphviz
2525
```
2626

27+
```{admonition} graphviz
28+
:class: warning
29+
If you are running this lecture locally it requires [graphviz](https://www.graphviz.org)
30+
to be installed on your computer. Installation instructions for graphviz can be found
31+
[here](https://www.graphviz.org/download/)
32+
```
33+
2734
+++ {"user_expressions": []}
2835

2936
## Overview

0 commit comments

Comments
 (0)