From 0ccb4f45df8e1a138d832444a9b889e7ffc81e5b Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 24 Jul 2025 11:51:16 +1000 Subject: [PATCH 01/14] ADJ[pdf]: figure cannot be nested for pdf --- lectures/matplotlib.md | 3 ++- lectures/numba.md | 3 ++- lectures/pandas.md | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lectures/matplotlib.md b/lectures/matplotlib.md index 3a47c0dc..5048ae7f 100644 --- a/lectures/matplotlib.md +++ b/lectures/matplotlib.md @@ -462,8 +462,9 @@ Place all the curves in the same figure. The output should look like this -```{figure} /_static/lecture_specific/matplotlib/matplotlib_ex1.png +```{image} /_static/lecture_specific/matplotlib/matplotlib_ex1.png :scale: 130 +:align: center ``` ```{exercise-end} diff --git a/lectures/numba.md b/lectures/numba.md index fb458daf..736b1b52 100644 --- a/lectures/numba.md +++ b/lectures/numba.md @@ -563,7 +563,8 @@ Suppose that the volatility of returns on an asset can be in one of two regimes The transition probabilities across states are as follows -```{figure} /_static/lecture_specific/sci_libs/nfs_ex1.png +```{image} /_static/lecture_specific/sci_libs/nfs_ex1.png +:align: center ``` For example, let the period length be one day, and suppose the current state is high. diff --git a/lectures/pandas.md b/lectures/pandas.md index 61bc5056..e2f93b75 100644 --- a/lectures/pandas.md +++ b/lectures/pandas.md @@ -682,8 +682,9 @@ ticker = read_data(ticker_list) Complete the program to plot the result as a bar graph like this one: -```{figure} /_static/lecture_specific/pandas/pandas_share_prices.png +```{image} /_static/lecture_specific/pandas/pandas_share_prices.png :scale: 80 +:align: center ``` ```{exercise-end} @@ -748,8 +749,9 @@ indices_list = {'^GSPC': 'S&P 500', Complete the program to show summary statistics and plot the result as a time series graph like this one: -```{figure} /_static/lecture_specific/pandas/pandas_indices_pctchange.png +```{image} /_static/lecture_specific/pandas/pandas_indices_pctchange.png :scale: 80 +:align: center ``` ```{exercise-end} From 6c930e3d2da66f927d93a9f82f356b994a7768a7 Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 24 Jul 2025 11:59:28 +1000 Subject: [PATCH 02/14] update software environment --- environment.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/environment.yml b/environment.yml index 11b6e1f7..d57d2cc0 100644 --- a/environment.yml +++ b/environment.yml @@ -2,12 +2,12 @@ name: quantecon channels: - default dependencies: - - python=3.12 - - anaconda=2024.10 + - python=3.13 + - anaconda=2025.06 - pip - pip: - - jupyter-book==1.0.3 - - quantecon-book-theme==0.8.2 + - jupyter-book==1.0.4post1 + - quantecon-book-theme==0.8.3 - sphinx-tojupyter==0.3.0 - sphinxext-rediraffe==0.2.7 - sphinx-exercise==1.0.1 From 67f236499091925be45b4e8ba87280c12f159781 Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 24 Jul 2025 12:21:37 +1000 Subject: [PATCH 03/14] update to latest software --- environment.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/environment.yml b/environment.yml index d57d2cc0..b560877c 100644 --- a/environment.yml +++ b/environment.yml @@ -11,8 +11,7 @@ dependencies: - sphinx-tojupyter==0.3.0 - sphinxext-rediraffe==0.2.7 - sphinx-exercise==1.0.1 - - ghp-import==2.1.0 - - sphinxcontrib-youtube==1.3.0 #Version 1.3.0 is required as quantecon-book-theme is only compatible with sphinx<=5 + - sphinxcontrib-youtube==1.4.1 - sphinx-togglebutton==0.3.2 From 216d3820a709ef8bae07aada20f74291361b64c6 Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 24 Jul 2025 12:29:26 +1000 Subject: [PATCH 04/14] update python=3.13 for all workflows --- .github/workflows/cache.yml | 2 +- .github/workflows/ci.yml | 2 +- .github/workflows/execution-linux.yml | 2 +- .github/workflows/execution-osx.yml | 2 +- .github/workflows/execution-win.yml | 2 +- .github/workflows/publish.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml index 438912c0..734d5174 100644 --- a/.github/workflows/cache.yml +++ b/.github/workflows/cache.yml @@ -14,7 +14,7 @@ jobs: auto-update-conda: true auto-activate-base: true miniconda-version: 'latest' - python-version: "3.12" + python-version: "3.13" environment-file: environment.yml activate-environment: quantecon - name: Build HTML diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75a1ee7d..6a7f36e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: auto-update-conda: true auto-activate-base: true miniconda-version: 'latest' - python-version: "3.12" + python-version: "3.13" environment-file: environment.yml activate-environment: quantecon - name: Install latex dependencies diff --git a/.github/workflows/execution-linux.yml b/.github/workflows/execution-linux.yml index fedc2e41..2ae72f73 100644 --- a/.github/workflows/execution-linux.yml +++ b/.github/workflows/execution-linux.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: os: ["ubuntu-latest"] - python-version: ["3.12"] + python-version: ["3.13"] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/execution-osx.yml b/.github/workflows/execution-osx.yml index b6aab55c..b3df8203 100644 --- a/.github/workflows/execution-osx.yml +++ b/.github/workflows/execution-osx.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: os: ["macos-latest"] - python-version: ["3.12"] + python-version: ["3.13"] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/execution-win.yml b/.github/workflows/execution-win.yml index 6f7e1ae3..f0bf9d34 100644 --- a/.github/workflows/execution-win.yml +++ b/.github/workflows/execution-win.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: os: ["windows-latest"] - python-version: ["3.12"] + python-version: ["3.13"] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 58cd14b6..88f354ce 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,7 +16,7 @@ jobs: auto-update-conda: true auto-activate-base: true miniconda-version: 'latest' - python-version: "3.12" + python-version: "3.13" environment-file: environment.yml activate-environment: quantecon - name: Install latex dependencies From ca80a0c72ea9eb0036dc1675def5c764d86fddb6 Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 24 Jul 2025 12:41:26 +1000 Subject: [PATCH 05/14] tmp: remove build cache --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a7f36e6..44fcac83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,13 +33,13 @@ jobs: - name: Display Pip Versions shell: bash -l {0} run: pip list - - name: Download "build" folder (cache) - uses: dawidd6/action-download-artifact@v11 - with: - workflow: cache.yml - branch: main - name: build-cache - path: _build + # - name: Download "build" folder (cache) + # uses: dawidd6/action-download-artifact@v11 + # with: + # workflow: cache.yml + # branch: main + # name: build-cache + # path: _build # Build Assets (Download Notebooks and PDF via LaTeX) - name: Build Download Notebooks (sphinx-tojupyter) shell: bash -l {0} From 8d829cd6170a8fae957e0b61503cba00101c8178 Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 24 Jul 2025 13:20:35 +1000 Subject: [PATCH 06/14] Revert "tmp: remove build cache" This reverts commit ca80a0c72ea9eb0036dc1675def5c764d86fddb6. --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44fcac83..6a7f36e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,13 +33,13 @@ jobs: - name: Display Pip Versions shell: bash -l {0} run: pip list - # - name: Download "build" folder (cache) - # uses: dawidd6/action-download-artifact@v11 - # with: - # workflow: cache.yml - # branch: main - # name: build-cache - # path: _build + - name: Download "build" folder (cache) + uses: dawidd6/action-download-artifact@v11 + with: + workflow: cache.yml + branch: main + name: build-cache + path: _build # Build Assets (Download Notebooks and PDF via LaTeX) - name: Build Download Notebooks (sphinx-tojupyter) shell: bash -l {0} From ad7c0c99a6aa071f018c68df281e1de7ed45527e Mon Sep 17 00:00:00 2001 From: mmcky Date: Mon, 28 Jul 2025 12:04:12 +1000 Subject: [PATCH 07/14] upgrade to sphinx-tojupyter==0.3.1 --- environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index b560877c..87316c85 100644 --- a/environment.yml +++ b/environment.yml @@ -8,7 +8,7 @@ dependencies: - pip: - jupyter-book==1.0.4post1 - quantecon-book-theme==0.8.3 - - sphinx-tojupyter==0.3.0 + - sphinx-tojupyter==0.3.1 - sphinxext-rediraffe==0.2.7 - sphinx-exercise==1.0.1 - sphinxcontrib-youtube==1.4.1 From 8ea2de7ae962723148ecf4674028bfc2ece24751 Mon Sep 17 00:00:00 2001 From: mmcky Date: Mon, 28 Jul 2025 12:27:24 +1000 Subject: [PATCH 08/14] tmp: disable build cache --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a7f36e6..44fcac83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,13 +33,13 @@ jobs: - name: Display Pip Versions shell: bash -l {0} run: pip list - - name: Download "build" folder (cache) - uses: dawidd6/action-download-artifact@v11 - with: - workflow: cache.yml - branch: main - name: build-cache - path: _build + # - name: Download "build" folder (cache) + # uses: dawidd6/action-download-artifact@v11 + # with: + # workflow: cache.yml + # branch: main + # name: build-cache + # path: _build # Build Assets (Download Notebooks and PDF via LaTeX) - name: Build Download Notebooks (sphinx-tojupyter) shell: bash -l {0} From c0957e230ca0cc83ad77d7cf741de50e0d5188c5 Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 31 Jul 2025 14:18:25 +1000 Subject: [PATCH 09/14] fix workspace.md --- .gitignore | 1 + lectures/workspace.md | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index d1e96dd0..a15f5193 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ dask-worker-space .ipynb_checkpoints/ .virtual_documents/ +lectures/sine_wave.py lectures/mathfoo.py lectures/mod.py lectures/test.py \ No newline at end of file diff --git a/lectures/workspace.md b/lectures/workspace.md index ad60f88c..fe175e5b 100644 --- a/lectures/workspace.md +++ b/lectures/workspace.md @@ -3,10 +3,12 @@ jupytext: text_representation: extension: .md format_name: myst + format_version: 0.13 + jupytext_version: 1.17.2 kernelspec: - display_name: Python 3 - language: python name: python3 + display_name: Python 3 (ipykernel) + language: python --- (workspace)= @@ -51,7 +53,7 @@ Python files are used when writing long, reusable blocks of code - by convention Let us begin by working with the following example. -```{code-block} python +```{code-cell} ipython3 :caption: sine_wave.py :lineno-start: 1 @@ -68,17 +70,18 @@ plt.title('Sine Wave') plt.show() ``` -The code is first saved locally on the computer before it is executed. - As there are various ways to execute the code, we will explore them in the context of different development environments. One major advantage of using Python scripts lies in the fact that you can "import" functionality from other scripts into your current script or Jupyter Notebook. -Let's rewrite the earlier code into a function. +Let's rewrite the earlier code into a function and write to to a file called `sine_wave.py`. -```{code-block} python +```{code-cell} ipython3 :caption: sine_wave.py :lineno-start: 1 + +%%writefile sine_wave.py + import matplotlib.pyplot as plt import numpy as np @@ -94,7 +97,7 @@ def plot_wave(title : str = 'Sine Wave'): plt.show() ``` -```{code-block} python +```{code-cell} ipython3 :caption: second_script.py :lineno-start: 1 @@ -345,9 +348,7 @@ In case you already haven't, try For example, if you've installed the command line version, open up a terminal and enter. -```{code-block} bash -:class: no-execute - +```bash git clone https://github.com/QuantEcon/QuantEcon.py ``` (This is just `git clone` in front of the URL for the repository) From 748a64c40099fc9f08eeb9eebd25bd8cd2065c2e Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 1 Aug 2025 09:54:51 +1000 Subject: [PATCH 10/14] re-enable build cache --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44fcac83..6a7f36e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,13 +33,13 @@ jobs: - name: Display Pip Versions shell: bash -l {0} run: pip list - # - name: Download "build" folder (cache) - # uses: dawidd6/action-download-artifact@v11 - # with: - # workflow: cache.yml - # branch: main - # name: build-cache - # path: _build + - name: Download "build" folder (cache) + uses: dawidd6/action-download-artifact@v11 + with: + workflow: cache.yml + branch: main + name: build-cache + path: _build # Build Assets (Download Notebooks and PDF via LaTeX) - name: Build Download Notebooks (sphinx-tojupyter) shell: bash -l {0} From 272ba8e6228898ce4a3bb5337d634e00136f7b35 Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 1 Aug 2025 10:03:14 +1000 Subject: [PATCH 11/14] adjust image in getting_started --- lectures/getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/getting_started.md b/lectures/getting_started.md index d6798fb5..ecb19613 100644 --- a/lectures/getting_started.md +++ b/lectures/getting_started.md @@ -376,7 +376,7 @@ You will spend a lot of time debugging code, so it is important to [learn how to If you are using a newer version of Jupyter, you should see a bug icon on the right end of the toolbar. ```{figure} /_static/lecture_specific/getting_started/debug.png -:scale: 80% +:scale: 50% :figclass: auto ``` From d1c899a36b96cc4fe3e7f6473f095b5e6ac285f5 Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 1 Aug 2025 10:08:48 +1000 Subject: [PATCH 12/14] update code block output --- lectures/oop_intro.md | 1 + 1 file changed, 1 insertion(+) diff --git a/lectures/oop_intro.md b/lectures/oop_intro.md index 708f1ee9..21787a1d 100644 --- a/lectures/oop_intro.md +++ b/lectures/oop_intro.md @@ -61,6 +61,7 @@ We'll make use of the following third party library ```{code-cell} python3 +:tags: [hide-output] !pip install rich ``` From 7a647351d1f3cd50f10b8541b73b69de023806cb Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 1 Aug 2025 10:22:44 +1000 Subject: [PATCH 13/14] fix synax warnings in matplotlib.md --- lectures/matplotlib.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lectures/matplotlib.md b/lectures/matplotlib.md index 5048ae7f..5e80dfd3 100644 --- a/lectures/matplotlib.md +++ b/lectures/matplotlib.md @@ -122,7 +122,7 @@ If everything is properly configured, then adding LaTeX is trivial ```{code-cell} python3 fig, ax = plt.subplots() -ax.plot(x, y, 'r-', linewidth=2, label='$y=\sin(x)$', alpha=0.6) +ax.plot(x, y, 'r-', linewidth=2, label=r'$y=\sin(x)$', alpha=0.6) ax.legend(loc='upper center') plt.show() ``` @@ -131,7 +131,7 @@ Controlling the ticks, adding titles and so on is also straightforward ```{code-cell} python3 fig, ax = plt.subplots() -ax.plot(x, y, 'r-', linewidth=2, label='$y=\sin(x)$', alpha=0.6) +ax.plot(x, y, 'r-', linewidth=2, label=r'$y=\sin(x)$', alpha=0.6) ax.legend(loc='upper center') ax.set_yticks([-1, 0, 1]) ax.set_title('Test plot') @@ -163,7 +163,7 @@ x = np.linspace(-4, 4, 150) for i in range(3): m, s = uniform(-1, 1), uniform(1, 2) y = norm.pdf(x, loc=m, scale=s) - current_label = f'$\mu = {m:.2}$' + current_label = rf'$\mu = {m:.2}$' ax.plot(x, y, linewidth=2, alpha=0.6, label=current_label) ax.legend() plt.show() @@ -186,7 +186,7 @@ for i in range(num_rows): m, s = uniform(-1, 1), uniform(1, 2) x = norm.rvs(loc=m, scale=s, size=100) axes[i, j].hist(x, alpha=0.6, bins=20) - t = f'$\mu = {m:.2}, \quad \sigma = {s:.2}$' + t = rf'$\mu = {m:.2}, \quad \sigma = {s:.2}$' axes[i, j].set(title=t, xticks=[-4, 0, 4], yticks=[]) plt.show() ``` @@ -419,7 +419,7 @@ x = np.linspace(-4, 4, 150) for i in range(3): m, s = uniform(-1, 1), uniform(1, 2) y = norm.pdf(x, loc=m, scale=s) - current_label = f'$\mu = {m:.2}$' + current_label = rf'$\mu = {m:.2}$' ax.plot(x, y, linewidth=2, alpha=0.6, label=current_label) ax.legend() plt.show() From f6e4d3fbfe14bab11803506a7ce122a9fea19bde Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 1 Aug 2025 10:26:19 +1000 Subject: [PATCH 14/14] remove FutureWarnings in pandas_panel --- lectures/pandas_panel.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lectures/pandas_panel.md b/lectures/pandas_panel.md index 9fd442b9..8bb6b29e 100644 --- a/lectures/pandas_panel.md +++ b/lectures/pandas_panel.md @@ -150,7 +150,7 @@ the row index (`.unstack()` works in the opposite direction - try it out) ```{code-cell} ipython3 -realwage.stack().head() +realwage.stack(future_stack=True).head() ``` We can also pass in an argument to select the level we would like to @@ -432,7 +432,7 @@ plt.show() summary statistics ```{code-cell} ipython3 -merged.stack().describe() +merged.stack(future_stack=True).describe() ``` This is a simplified way to use `groupby`.