Skip to content

Commit d6bd805

Browse files
committed
Merge branch 'main' of https://github.com/QuantEcon/lecture-python.myst into cass_fiscal
2 parents b9baa9c + 07433c8 commit d6bd805

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+326
-382
lines changed

.github/workflows/cache.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name: Build Cache [using jupyter-book]
22
on:
3-
push:
4-
branches:
5-
- main
3+
schedule:
4+
# Execute cache weekly at 3am on Monday
5+
- cron: '0 3 * * 1'
66
jobs:
77
cache:
8-
runs-on: quantecon-gpu-runner
8+
runs-on: quantecon-gpu
99
container:
10-
image: ghcr.io/quantecon/lecture-python-container:cuda-12.6.0-anaconda-2024-06-py312
10+
image: ghcr.io/quantecon/lecture-python-container:cuda-12.6.0-anaconda-2024-10-py312-b
1111
options: --gpus all
1212
steps:
1313
- uses: actions/checkout@v4
@@ -31,4 +31,5 @@ jobs:
3131
uses: actions/upload-artifact@v4
3232
with:
3333
name: build-cache
34-
path: _build
34+
path: _build
35+
include-hidden-files: true

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Build Project [using jupyter-book]
22
on: [pull_request]
33
jobs:
44
preview:
5-
runs-on: quantecon-gpu-runner
5+
runs-on: quantecon-gpu
66
container:
7-
image: ghcr.io/quantecon/lecture-python-container:cuda-12.6.0-anaconda-2024-06-py312
7+
image: ghcr.io/quantecon/lecture-python-container:cuda-12.6.0-anaconda-2024-10-py312-b
88
options: --gpus all
99
steps:
1010
- uses: actions/checkout@v4
@@ -21,7 +21,7 @@ jobs:
2121
shell: bash -l {0}
2222
run: pip list
2323
- name: Download "build" folder (cache)
24-
uses: dawidd6/action-download-artifact@v6
24+
uses: dawidd6/action-download-artifact@v7
2525
with:
2626
workflow: cache.yml
2727
branch: main
@@ -64,7 +64,7 @@ jobs:
6464
name: execution-reports
6565
path: _build/html/reports
6666
- name: Preview Deploy to Netlify
67-
uses: nwtgck/actions-netlify@v3.0
67+
uses: nwtgck/actions-netlify@v3
6868
with:
6969
publish-dir: '_build/html/'
7070
production-branch: main

.github/workflows/collab.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build Project on Google Collab (Execution)
2+
on: [pull_request]
3+
jobs:
4+
execution-checks:
5+
runs-on: quantecon-gpu
6+
container:
7+
image: docker://us-docker.pkg.dev/colab-images/public/runtime
8+
options: --gpus all
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
ref: ${{ github.event.pull_request.head.sha }}
13+
- name: Check nvidia drivers
14+
shell: bash -l {0}
15+
run: |
16+
nvidia-smi
17+
- name: Check python version
18+
shell: bash -l {0}
19+
run: |
20+
python --version
21+
- name: Display Pip Versions
22+
shell: bash -l {0}
23+
run: pip list
24+
- name: Download "build" folder (cache)
25+
uses: dawidd6/action-download-artifact@v7
26+
with:
27+
workflow: cache.yml
28+
branch: main
29+
name: build-cache
30+
path: _build
31+
# Install build software
32+
- name: Install Build Software
33+
shell: bash -l {0}
34+
run: |
35+
pip install jupyter-book==0.15.1 docutils==0.17.1 quantecon-book-theme==0.7.2 sphinx-tojupyter==0.3.0 sphinxext-rediraffe==0.2.7 sphinx-reredirects sphinx-exercise==0.4.1 sphinxcontrib-youtube==1.1.0 sphinx-togglebutton==0.3.1 arviz==0.13.0
36+
# Build of HTML (Execution Testing)
37+
- name: Build HTML
38+
shell: bash -l {0}
39+
run: |
40+
jb build lectures --path-output ./ -n -W --keep-going
41+
- name: Upload Execution Reports
42+
uses: actions/upload-artifact@v4
43+
if: failure()
44+
with:
45+
name: execution-reports
46+
path: _build/html/reports
47+
- name: Preview Deploy to Netlify
48+
uses: nwtgck/actions-netlify@v3
49+
with:
50+
publish-dir: '_build/html/'
51+
production-branch: main
52+
github-token: ${{ secrets.GITHUB_TOKEN }}
53+
deploy-message: "Preview Deploy from GitHub Actions"
54+
env:
55+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
56+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

.github/workflows/execution.yml

Lines changed: 0 additions & 111 deletions
This file was deleted.

.github/workflows/linkcheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
environment-file: environment.yml
2828
activate-environment: quantecon
2929
- name: Download "build" folder (cache)
30-
uses: dawidd6/action-download-artifact@v6
30+
uses: dawidd6/action-download-artifact@v7
3131
with:
3232
workflow: cache.yml
3333
branch: main

.github/workflows/publish.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ on:
66
jobs:
77
publish:
88
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
9-
runs-on: quantecon-gpu-runner
9+
runs-on: quantecon-gpu
1010
container:
11-
image: ghcr.io/quantecon/lecture-python-container:cuda-12.6.0-anaconda-2024-06-py312
11+
image: ghcr.io/quantecon/lecture-python-container:cuda-12.6.0-anaconda-2024-10-py312-b
1212
options: --gpus all
1313
steps:
1414
- name: Checkout
@@ -28,7 +28,7 @@ jobs:
2828
run: pip list
2929
# Download Build Cache from cache.yml
3030
- name: Download "build" folder (cache)
31-
uses: dawidd6/action-download-artifact@v6
31+
uses: dawidd6/action-download-artifact@v7
3232
with:
3333
workflow: cache.yml
3434
branch: main
@@ -90,4 +90,4 @@ jobs:
9090
git config user.email "[email protected]"
9191
git add *.ipynb
9292
git commit -m "auto publishing updates to notebooks"
93-
git push origin master
93+
git push origin main

environment.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@ channels:
33
- default
44
dependencies:
55
- python=3.12
6-
- anaconda=2024.06
6+
- anaconda=2024.10
77
- pip
88
- pip:
9-
- jupyter-book==0.15.1
10-
- docutils==0.17.1
11-
- quantecon-book-theme==0.7.1
12-
- sphinx-reredirects==0.1.3
9+
- jupyter-book==1.0.3
10+
- quantecon-book-theme==0.7.6
1311
- sphinx-tojupyter==0.3.0
1412
- sphinxext-rediraffe==0.2.7
15-
- sphinx-exercise==0.4.1
16-
- ghp-import==2.1.0
17-
- sphinxcontrib-youtube==1.2.0
13+
- sphinx-reredirects==0.1.4
14+
- sphinx-exercise==1.0.1
15+
- sphinx-proof==0.2.0
16+
- ghp-import==1.1.0
17+
- sphinxcontrib-youtube==1.3.0 #Version 1.3.0 is required as quantecon-book-theme is only compatible with sphinx<=5
1818
- sphinx-togglebutton==0.3.2
19-
- arviz==0.13.0
20-
- kaleido
2119
# Docker Requirements
2220
- pytz
21+

lectures/_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ latex:
3434
sphinx:
3535
extra_extensions: [sphinx_multitoc_numbering, sphinxext.rediraffe, sphinx_tojupyter, sphinxcontrib.youtube, sphinx.ext.todo, sphinx_exercise, sphinx_proof, sphinx_togglebutton, sphinx.ext.intersphinx, sphinx_reredirects]
3636
config:
37+
# false-positive links
38+
linkcheck_ignore: ['https://online.stat.psu.edu/stat415/book/export/html/834']
3739
bibtex_reference_style: author_year
3840
nb_mime_priority_overrides: [
3941
# HTML

lectures/aiyagari.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ kernelspec:
1010
---
1111

1212
(aiyagari)=
13-
```{raw} html
13+
```{raw} jupyter
1414
<div id="qe-notebook-header" align="right" style="text-align:right;">
1515
<a href="https://quantecon.org/" title="quantecon.org">
1616
<img style="width:250px;display:inline;" width="250px" src="https://assets.quantecon.org/img/qe-menubar-logo.svg" alt="QuantEcon">
@@ -283,7 +283,7 @@ class Household:
283283
284284
# Do the hard work using JIT-ed functions
285285
286-
@jit(nopython=True)
286+
@jit
287287
def populate_R(R, a_size, z_size, a_vals, z_vals, r, w):
288288
n = a_size * z_size
289289
for s_i in range(n):
@@ -297,7 +297,7 @@ def populate_R(R, a_size, z_size, a_vals, z_vals, r, w):
297297
if c > 0:
298298
R[s_i, new_a_i] = np.log(c) # Utility
299299
300-
@jit(nopython=True)
300+
@jit
301301
def populate_Q(Q, a_size, z_size, Π):
302302
n = a_size * z_size
303303
for s_i in range(n):
@@ -307,7 +307,7 @@ def populate_Q(Q, a_size, z_size, Π):
307307
Q[s_i, a_i, a_i*z_size + next_z_i] = Π[z_i, next_z_i]
308308
309309
310-
@jit(nopython=True)
310+
@jit
311311
def asset_marginal(s_probs, a_size, z_size):
312312
a_probs = np.zeros(a_size)
313313
for a_i in range(a_size):

lectures/ak2.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ $$
408408
```{code-cell} ipython3
409409
import numpy as np
410410
import matplotlib.pyplot as plt
411-
from numba import njit
411+
from numba import jit
412412
from quantecon.optimize import brent_max
413413
```
414414
@@ -433,22 +433,22 @@ Knowing $\hat K$, we can calculate other equilibrium objects.
433433
Let's first define some Python helper functions.
434434
435435
```{code-cell} ipython3
436-
@njit
436+
@jit
437437
def K_to_Y(K, α):
438438
439439
return K ** α
440440
441-
@njit
441+
@jit
442442
def K_to_r(K, α):
443443
444444
return α * K ** (α - 1)
445445
446-
@njit
446+
@jit
447447
def K_to_W(K, α):
448448
449449
return (1 - α) * K ** α
450450
451-
@njit
451+
@jit
452452
def K_to_C(K, D, τ, r, α, β):
453453
454454
# optimal consumption for the old when δ=0
@@ -913,7 +913,7 @@ Let's implement this "guess and verify" approach
913913
We start by defining the Cobb-Douglas utility function
914914
915915
```{code-cell} ipython3
916-
@njit
916+
@jit
917917
def U(Cy, Co, β):
918918
919919
return (Cy ** β) * (Co ** (1-β))
@@ -924,7 +924,7 @@ We use `Cy_val` to compute the lifetime value of an arbitrary consumption plan,
924924
Note that it requires knowing future prices $r_{t+1}$ and tax rate $\tau_{t+1}$.
925925
926926
```{code-cell} ipython3
927-
@njit
927+
@jit
928928
def Cy_val(Cy, W, r_next, τ, τ_next, δy, δo_next, β):
929929
930930
# Co given by the budget constraint

0 commit comments

Comments
 (0)