Skip to content

Commit 4820487

Browse files
authored
ENH: Enable Execution, GitHub Actions, update config.yml (#4)
* amss lecture literalinclude -> code-cell * opt_tax_recur lecture literalinclude -> code-cell * amss2 lecture literalinclude -> code-cell * amss3 lecture literalinclude -> code-cell * chang_credible lecture literalinclude -> code-cell * chang_ramsey lecture literalinclude -> code-cell * classical_filtering lecture literalinclude -> code-cell * lu_tricks lecture literalinclude -> code-cell * rob_markov_perf lecture literalinclude -> code-cell * install myst_nb from branch for testing * install mysb_nb from branch for testing * switch on execution * myst_nb now supports code-cell from file * add in upgrade for tornado while fixing environment * specify priority for notebook outputs * [TEST] see if ipython display shows the image for html * change :file: to :load: * migrate file: to load: for multi-argument output * add execution status page * [medium term] this shows what the output should look like and leaves mybinder for the interactive plot at the end * add note about ipywidgets and html * fix timeout from 60s to 600s (10min) per lecture * enable run times per lecture of up to 20 minutes * harmonise _config.yml with lecture-python.myst * install quantecon-book-theme from main on github * removing output so that failed javascript objects don't get added * remove output from other uses of @interact * add notes about interactive plots on website * move to using quantecon-book-theme from pip * [TEST] demote javascript and jupyter widgets for html builder * Revert "[TEST] demote javascript and jupyter widgets for html builder" This reverts commit a881d8f. * [TEST] build using quantecon-book-theme@refactor as test for upcoming quantecon-book-theme=0.2.0 * Revert "Merge branch 'fix-ipywidgets' into fix-codefromfile" This reverts commit 37a63a3, reversing changes made to caf175a. * Revert "Merge branch 'fix-ipywidgets' into fix-codefromfile" This reverts commit caf175a, reversing changes made to 4a4f625. * [TEST] install from master to test upcoming 0.2.0 * remove tornado update in favour of updated environmnent.yml * check output_scroll tag * Revert "check output_scroll tag" This reverts commit bb51afd. * remove testing for interact and open in different PR
1 parent f6dcddb commit 4820487

File tree

12 files changed

+106
-38
lines changed

12 files changed

+106
-38
lines changed

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
1010
- sphinx-multitoc-numbering
11-
- quantecon-book-theme
11+
- git+https://github.com/QuantEcon/quantecon-book-theme
1212
- sphinx-tojupyter
1313
- sphinxext-rediraffe
1414
- sphinx-exercise

lectures/_config.yml

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,74 @@
11
title: Advanced Quantitative Economics with Python
22
author: Thomas J. Sargent & John Stachurski
33
logo: _static/qe-logo-large.png
4+
description: This website presents a set of lectures on advanced quantitative economic modeling, designed and written by Thomas J. Sargent and John Stachurski.
45

56
execute:
6-
execute_notebooks: "off"
7-
timeout: 60
8-
# run_in_temp: true
7+
execute_notebooks: "cache"
8+
timeout: 1200
99

1010
bibtex_bibfiles:
1111
- _static/quant-econ.bib
1212

13+
html:
14+
baseurl: https://python-advanced.quantecon.org/
15+
1316
sphinx:
14-
extra_extensions: [sphinx_multitoc_numbering]
17+
extra_extensions: [sphinx_multitoc_numbering, sphinxext.rediraffe, sphinx_tojupyter]
1518
config:
19+
nb_render_priority:
20+
html:
21+
- "application/vnd.jupyter.widget-view+json"
22+
- "application/javascript"
23+
- "text/html"
24+
- "text/latex"
25+
- "image/svg+xml"
26+
- "image/png"
27+
- "image/jpeg"
28+
- "text/markdown"
29+
- "text/plain"
30+
jupyter:
31+
- "application/vnd.jupyter.widget-view+json"
32+
- "application/javascript"
33+
- "text/html"
34+
- "text/latex"
35+
- "image/svg+xml"
36+
- "image/png"
37+
- "image/jpeg"
38+
- "text/markdown"
39+
- "text/plain"
40+
html_favicon: _static/lectures-favicon.ico
1641
html_theme: quantecon_book_theme
1742
html_static_path: ['_static']
43+
html_theme_options:
44+
header_organisation_url: https://quantecon.org
45+
header_organisation: QuantEcon
46+
repository_url: https://github.com/QuantEcon/lecture-python-advanced.myst
47+
nb_repository_url: https://github.com/QuantEcon/lecture-python-advanced.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 a set of lectures on advanced quantitative economic modeling, 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
53+
google_analytics_id: UA-54984338-11
1854
mathjax_config:
1955
TeX:
2056
Macros:
2157
"argmax" : "arg\\,max"
2258
"argmin" : "arg\\,min"
2359
mathjax_path: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
60+
rediraffe_redirects:
61+
index_toc.md: intro.md
62+
tojupyter_static_file_path: ["source/_static", "_static"]
63+
tojupyter_target_html: true
64+
tojupyter_urlpath: "https://python-advanced.quantecon.org/"
65+
tojupyter_image_urlpath: "https://python-advanced.quantecon.org/_static/"
66+
tojupyter_lang_synonyms: ["ipython", "ipython3", "python"]
67+
tojupyter_kernels:
68+
python3:
69+
kernelspec:
70+
display_name: "Python"
71+
language: python3
72+
name: python3
73+
file_extension: ".py"
74+
tojupyter_images_markdown: true

lectures/amss.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,9 @@ in a Lucas-Stokey economy with state-contingent government debt.
400400
We need some code from {doc}`an earlier lecture <opt_tax_recur>`
401401
on optimal taxation with state-contingent debt sequential allocation implementation:
402402

403-
```{literalinclude} _static/lecture_specific/opt_tax_recur/sequential_allocation.py
403+
```{code-cell} python3
404404
---
405+
load: _static/lecture_specific/opt_tax_recur/sequential_allocation.py
405406
tags: [output_scroll]
406407
---
407408
```
@@ -672,7 +673,8 @@ assets, returning any excess revenues to the household as non-negative lump-sum
672673

673674
The recursive formulation is implemented as follows
674675

675-
```{literalinclude} _static/lecture_specific/amss/recursive_allocation.py
676+
```{code-cell} python3
677+
:load: _static/lecture_specific/amss/recursive_allocation.py
676678
```
677679

678680
## Examples
@@ -681,7 +683,8 @@ We now turn to some examples.
681683

682684
We will first build some useful functions for solving the model
683685

684-
```{literalinclude} _static/lecture_specific/amss/utilities.py
686+
```{code-cell} python3
687+
:load: _static/lecture_specific/amss/utilities.py
685688
```
686689

687690
### Anticipated One-Period War
@@ -742,7 +745,8 @@ We assume the same utility parameters as in the {doc}`Lucas-Stokey economy <opt_
742745

743746
This utility function is implemented in the following class.
744747

745-
```{literalinclude} _static/lecture_specific/opt_tax_recur/crra_utility.py
748+
```{code-cell} python3
749+
:load: _static/lecture_specific/opt_tax_recur/crra_utility.py
746750
```
747751

748752
The following figure plots Ramsey plans under complete and incomplete
@@ -866,7 +870,8 @@ $$
866870

867871
In accordance, we will re-define our utility function.
868872

869-
```{literalinclude} _static/lecture_specific/opt_tax_recur/log_utility.py
873+
```{code-cell} python3
874+
:load: _static/lecture_specific/opt_tax_recur/log_utility.py
870875
```
871876

872877
With these preferences, Ramsey tax rates will vary even in the Lucas-Stokey

lectures/amss2.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ In equation {eq}`amss2_TS_barg10`, it is understood that $c$ and $g$ are each fu
245245

246246
The CRRA utility function is represented in the following class.
247247

248-
```{literalinclude} _static/lecture_specific/opt_tax_recur/crra_utility.py
248+
```{code-cell} python3
249+
:load: _static/lecture_specific/opt_tax_recur/crra_utility.py
249250
```
250251

251252
## Example Economy
@@ -275,20 +276,23 @@ Here are several classes that do most of the work for us.
275276
The code is mostly taken or adapted from the earlier lectures {doc}`optimal taxation without state-contingent debt <amss>` and
276277
{doc}`optimal taxation with state-contingent debt <opt_tax_recur>`.
277278

278-
```{literalinclude} _static/lecture_specific/opt_tax_recur/sequential_allocation.py
279+
```{code-cell} python3
279280
---
281+
load: _static/lecture_specific/opt_tax_recur/sequential_allocation.py
280282
tags: [output_scroll]
281283
---
282284
```
283285

284-
```{literalinclude} _static/lecture_specific/amss/recursive_allocation.py
286+
```{code-cell} python3
285287
---
288+
load: _static/lecture_specific/amss/recursive_allocation.py
286289
tags: [output_scroll]
287290
---
288291
```
289292

290-
```{literalinclude} _static/lecture_specific/amss/utilities.py
293+
```{code-cell} python3
291294
---
295+
load: _static/lecture_specific/amss/utilities.py
292296
tags: [output_scroll]
293297
---
294298
```

lectures/amss3.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ $$
116116

117117
The following Python code sets up the economy
118118

119-
```{literalinclude} _static/lecture_specific/opt_tax_recur/crra_utility.py
119+
```{code-cell} python3
120+
:load: _static/lecture_specific/opt_tax_recur/crra_utility.py
120121
```
121122

122123
### First and Second Moments
@@ -148,20 +149,23 @@ We begin by showing the code that we used in earlier lectures on the AMSS model.
148149

149150
Here it is
150151

151-
```{literalinclude} _static/lecture_specific/opt_tax_recur/sequential_allocation.py
152+
```{code-cell} python3
152153
---
154+
load: _static/lecture_specific/opt_tax_recur/sequential_allocation.py
153155
tags: [output_scroll]
154156
---
155157
```
156158

157-
```{literalinclude} _static/lecture_specific/amss/recursive_allocation.py
159+
```{code-cell} python3
158160
---
161+
load: _static/lecture_specific/amss/recursive_allocation.py
159162
tags: [output_scroll]
160163
---
161164
```
162165

163-
```{literalinclude} _static/lecture_specific/amss/utilities.py
166+
```{code-cell} python3
164167
---
168+
load: _static/lecture_specific/amss/utilities.py
165169
tags: [output_scroll]
166170
---
167171
```

lectures/chang_credible.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,8 +809,9 @@ code for now. We can increase accuracy by increasing the number of subgradients)
809809

810810
The following code computes sustainable plans
811811

812-
```{literalinclude} _static/lecture_specific/chang_credible/changecon.py
812+
```{code-cell} python3
813813
---
814+
load: _static/lecture_specific/chang_credible/changecon.py
814815
tags: [output_scroll]
815816
---
816817
```

lectures/chang_ramsey.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,8 @@ $\beta = 0.8$.
882882
(Here we have set the number of subgradients to 10 in order to speed up the
883883
code for now - we can increase accuracy by increasing the number of subgradients)
884884

885-
```{literalinclude} _static/lecture_specific/chang_credible/changecon.py
885+
```{code-cell} python3
886+
:load: _static/lecture_specific/chang_credible/changecon.py
886887
```
887888

888889
```{code-cell} python3

lectures/classical_filtering.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ $$
225225

226226
Here's the code that computes solutions to LQ control and filtering problems using the methods described here and in {doc}`Classical Control with Linear Algebra <lu_tricks>`.
227227

228-
```{literalinclude} _static/lecture_specific/lu_tricks/control_and_filter.py
228+
```{code-cell} python3
229+
:load: _static/lecture_specific/lu_tricks/control_and_filter.py
229230
```
230231

231232
Let's use this code to tackle two interesting examples.

lectures/lu_tricks.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,8 @@ solving a related undiscounted problem.
892892
Here's the code that computes solutions to the LQ problem using the methods described
893893
above.
894894

895-
```{literalinclude} _static/lecture_specific/lu_tricks/control_and_filter.py
895+
```{code-cell} python3
896+
:load: _static/lecture_specific/lu_tricks/control_and_filter.py
896897
```
897898

898899
### Example

lectures/opt_tax_recur.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,8 @@ $$
719719

720720
The above steps are implemented in a class called SequentialAllocation
721721

722-
```{literalinclude} _static/lecture_specific/opt_tax_recur/sequential_allocation.py
722+
```{code-cell} python3
723+
:load: _static/lecture_specific/opt_tax_recur/sequential_allocation.py
723724
```
724725

725726
## Recursive Formulation of the Ramsey Problem
@@ -1020,7 +1021,8 @@ through them, the value of initial government debt $b_0$.
10201021

10211022
The above steps are implemented in a class called `RecursiveAllocation`.
10221023

1023-
```{literalinclude} _static/lecture_specific/opt_tax_recur/recursive_allocation.py
1024+
```{code-cell} python3
1025+
:load: _static/lecture_specific/opt_tax_recur/recursive_allocation.py
10241026
```
10251027

10261028
## Examples
@@ -1073,7 +1075,8 @@ utility as a function of $n$ rather than leisure $l$.
10731075

10741076
This utility function is implemented in the class `CRRAutility`.
10751077

1076-
```{literalinclude} _static/lecture_specific/opt_tax_recur/crra_utility.py
1078+
```{code-cell} python3
1079+
:load: _static/lecture_specific/opt_tax_recur/crra_utility.py
10771080
```
10781081

10791082
We set initial government debt $b_0 = 1$.
@@ -1351,7 +1354,8 @@ $$
13511354

13521355
We will create a new class LogUtility to represent this utility function
13531356

1354-
```{literalinclude} _static/lecture_specific/opt_tax_recur/log_utility.py
1357+
```{code-cell} python3
1358+
:load: _static/lecture_specific/opt_tax_recur/log_utility.py
13551359
```
13561360

13571361
Also, suppose that $g_t$ follows a two-state IID process with equal

0 commit comments

Comments
 (0)