Skip to content

Commit cbe5d6a

Browse files
authored
Merge branch 'main' into translation-sync-2026-04-09T02-08-09-pr-491
2 parents 6cadff3 + 7b3fc41 commit cbe5d6a

24 files changed

+227
-0
lines changed

.github/workflows/cache.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Build Cache [using jupyter-book]
2+
on:
3+
schedule:
4+
# Execute cache weekly at 3am on Monday
5+
- cron: '0 3 * * 1'
6+
workflow_dispatch:
7+
8+
jobs:
9+
cache:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Setup Anaconda
14+
uses: conda-incubator/setup-miniconda@v3
15+
with:
16+
auto-update-conda: true
17+
auto-activate-base: true
18+
miniconda-version: 'latest'
19+
python-version: "3.13"
20+
environment-file: environment.yml
21+
activate-environment: quantecon
22+
- name: Install JAX (CPU)
23+
shell: bash -l {0}
24+
run: |
25+
pip install jax
26+
- name: Display Conda Environment Versions
27+
shell: bash -l {0}
28+
run: conda list
29+
- name: Display Pip Versions
30+
shell: bash -l {0}
31+
run: pip list
32+
- name: Build HTML
33+
shell: bash -l {0}
34+
run: |
35+
jb build lectures --path-output ./ -W --keep-going
36+
- name: Upload Execution Reports
37+
uses: actions/upload-artifact@v4
38+
if: failure()
39+
with:
40+
name: execution-reports
41+
path: _build/html/reports
42+
- name: Upload "_build" folder (cache)
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: build-cache
46+
path: _build
47+
include-hidden-files: true

.github/workflows/ci.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build Project [using jupyter-book]
2+
on: [pull_request]
3+
4+
permissions:
5+
contents: read
6+
actions: read
7+
8+
jobs:
9+
preview:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Setup Anaconda
14+
uses: conda-incubator/setup-miniconda@v3
15+
with:
16+
auto-update-conda: true
17+
auto-activate-base: true
18+
miniconda-version: 'latest'
19+
python-version: "3.13"
20+
environment-file: environment.yml
21+
activate-environment: quantecon
22+
- name: Install JAX (CPU)
23+
shell: bash -l {0}
24+
run: |
25+
pip install jax
26+
- name: Display Conda Environment Versions
27+
shell: bash -l {0}
28+
run: conda list
29+
- name: Display Pip Versions
30+
shell: bash -l {0}
31+
run: pip list
32+
- name: Download "build" folder (cache)
33+
uses: dawidd6/action-download-artifact@v6
34+
with:
35+
workflow: cache.yml
36+
branch: main
37+
name: build-cache
38+
path: _build
39+
# Build Assets (Download Notebooks)
40+
- name: Build Download Notebooks (sphinx-tojupyter)
41+
shell: bash -l {0}
42+
run: |
43+
jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter -n -W --keep-going
44+
mkdir -p _build/html/_notebooks
45+
cp -u _build/jupyter/*.ipynb _build/html/_notebooks
46+
# Final Build of HTML
47+
- name: Build HTML
48+
shell: bash -l {0}
49+
run: |
50+
jb build lectures --path-output ./ -n -W --keep-going
51+
- name: Upload Execution Reports
52+
uses: actions/upload-artifact@v4
53+
if: failure()
54+
with:
55+
name: execution-reports
56+
path: _build/html/reports

.github/workflows/publish.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Build & Publish to GH Pages
2+
on:
3+
push:
4+
tags:
5+
- 'publish*'
6+
7+
permissions:
8+
contents: read
9+
actions: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
publish:
19+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
20+
runs-on: ubuntu-latest
21+
environment:
22+
name: github-pages
23+
url: ${{ steps.deployment.outputs.page_url }}
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
- name: Setup Anaconda
28+
uses: conda-incubator/setup-miniconda@v3
29+
with:
30+
auto-update-conda: true
31+
auto-activate-base: true
32+
miniconda-version: 'latest'
33+
python-version: "3.13"
34+
environment-file: environment.yml
35+
activate-environment: quantecon
36+
- name: Install JAX (CPU)
37+
shell: bash -l {0}
38+
run: |
39+
pip install jax
40+
- name: Display Conda Environment Versions
41+
shell: bash -l {0}
42+
run: conda list
43+
- name: Display Pip Versions
44+
shell: bash -l {0}
45+
run: pip list
46+
# Download Build Cache from cache.yml
47+
- name: Download "build" folder (cache)
48+
uses: dawidd6/action-download-artifact@v6
49+
with:
50+
workflow: cache.yml
51+
branch: main
52+
name: build-cache
53+
path: _build
54+
# Build Assets (Download Notebooks)
55+
- name: Build Download Notebooks (sphinx-tojupyter)
56+
shell: bash -l {0}
57+
run: |
58+
jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter -n -W --keep-going
59+
mkdir -p _build/html/_notebooks
60+
cp -u _build/jupyter/*.ipynb _build/html/_notebooks
61+
# Final Build of HTML (with assets)
62+
- name: Build HTML
63+
shell: bash -l {0}
64+
run: |
65+
jb build lectures --path-output ./ -n -W --keep-going
66+
- name: Upload Execution Reports
67+
uses: actions/upload-artifact@v4
68+
if: failure()
69+
with:
70+
name: execution-reports
71+
path: _build/html/reports
72+
- name: Setup Pages
73+
uses: actions/configure-pages@v4
74+
- name: Upload Pages artifact
75+
uses: actions/upload-pages-artifact@v3
76+
with:
77+
path: _build/html/
78+
- name: Deploy to GitHub Pages
79+
id: deployment
80+
uses: actions/deploy-pages@v4

environment.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: quantecon
2+
channels:
3+
- defaults
4+
dependencies:
5+
- python=3.13
6+
- anaconda=2025.12
7+
- pip
8+
- pip:
9+
- jupyter-book>=1.0.4post1,<2.0
10+
- quantecon-book-theme==0.20.0
11+
- sphinx-tojupyter==0.6.0
12+
- sphinxext-rediraffe==0.3.0
13+
- sphinx-exercise==1.2.1
14+
- sphinx-togglebutton==0.4.5

lectures/_admonition/gpu.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
```{admonition} GPU
2+
:class: warning
3+
4+
本讲座使用了配备 GPU 的机器进行构建——但没有 GPU 也可以运行。
5+
6+
[Google Colab](https://colab.research.google.com/) 提供了免费的 GPU 访问,
7+
您可以按照以下步骤使用:
8+
9+
1. 点击右上角的"play"图标
10+
2. 选择 Colab
11+
3. 将运行时环境设置为包含 GPU
12+
```
23.6 MB
Binary file not shown.

lectures/about_py.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ a
316316
```{code-cell} python3
317317
import numpy as np # 加载库
318318
import matplotlib as mpl # i18n
319+
import matplotlib.font_manager # i18n
319320
FONTPATH = "_fonts/SourceHanSerifSC-SemiBold.otf" # i18n
320321
mpl.font_manager.fontManager.addfont(FONTPATH) # i18n
321322
mpl.rcParams['font.family'] = ['Source Han Serif SC'] # i18n

lectures/debugging.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Python 的调试工具因平台、集成开发环境和编辑器的不同而有
7272
import numpy as np
7373
import matplotlib.pyplot as plt
7474
import matplotlib as mpl # i18n
75+
import matplotlib.font_manager # i18n
7576
FONTPATH = "_fonts/SourceHanSerifSC-SemiBold.otf" # i18n
7677
mpl.font_manager.fontManager.addfont(FONTPATH) # i18n
7778
mpl.rcParams['font.family'] = ['Source Han Serif SC'] # i18n

lectures/functions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ translation:
6262
import numpy as np
6363
import matplotlib.pyplot as plt
6464
import matplotlib as mpl # i18n
65+
import matplotlib.font_manager # i18n
6566
FONTPATH = "_fonts/SourceHanSerifSC-SemiBold.otf" # i18n
6667
mpl.font_manager.fontManager.addfont(FONTPATH) # i18n
6768
mpl.rcParams['font.family'] = ['Source Han Serif SC'] # i18n

lectures/jax_intro.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ import quantecon as qe
8686
```{code-cell} ipython3
8787
import jax.numpy as jnp
8888
import matplotlib as mpl # i18n
89+
import matplotlib.font_manager # i18n
8990
FONTPATH = "_fonts/SourceHanSerifSC-SemiBold.otf" # i18n
9091
mpl.font_manager.fontManager.addfont(FONTPATH) # i18n
9192
mpl.rcParams['font.family'] = ['Source Han Serif SC'] # i18n

0 commit comments

Comments
 (0)