diff --git a/.github/workflows/ci_pr.yml b/.github/workflows/ci_pr.yml index bd0b8fb..73dc01c 100644 --- a/.github/workflows/ci_pr.yml +++ b/.github/workflows/ci_pr.yml @@ -3,12 +3,10 @@ name: Build and Netlify Deploy on: pull_request: branches: - - main - paths: - - book/** - - requirements.txt - - .github/workflows/deploy.yml - - .github/workflows/ci_pr.yml + - theme_updates + push: + branches: + - theme_updates workflow_dispatch: concurrency: @@ -25,7 +23,7 @@ jobs: permissions: contents: read pull-requests: write - + steps: - name: Checkout current branch uses: actions/checkout@v4 @@ -41,169 +39,32 @@ jobs: echo "PR number: ${{ github.event.number }}" echo "Commit SHA: ${{ github.sha }}" - - name: Record extra cache info - run: | - # Record filenames listing -- this updates the cache on filename change - find book/ -type f >> EXTRA_CACHE_VARS.txt - # For PR builds, we don't preprocess or archive - echo false >> EXTRA_CACHE_VARS.txt # preprocess - echo false >> EXTRA_CACHE_VARS.txt # archive - cat EXTRA_CACHE_VARS.txt - - - name: Cache page build - id: cache-html - uses: actions/cache@v4 - with: - path: "book/_build/html" - key: html-build-${{ github.head_ref }}-${{ hashFiles('book/**', 'requirements.txt', 'EXTRA_CACHE_VARS.txt') }} - - - if: ${{ steps.cache-html.outputs.cache-hit != 'true' }} - name: Set up Python 3.11 - uses: actions/setup-python@v5 - id: setup-python - with: - python-version: 3.11 - - if: ${{ steps.cache-html.outputs.cache-hit != 'true' }} - name: Record current date for cache - run: | - echo "WEEK=$(date +%V)" >> $GITHUB_ENV - - - if: ${{ steps.cache-html.outputs.cache-hit != 'true' }} - name: Cache virtualenv - uses: actions/cache@v4 + - uses: actions/setup-node@v4 with: - key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}-week${{ env.WEEK }}-${{ github.repository }} - path: .venv + node-version: 18.x - - if: ${{ steps.cache-html.outputs.cache-hit != 'true' }} - name: Install dependencies + - name: Install MyST Markdown CLI run: | - python -m venv .venv - source .venv/bin/activate - python -m pip install -r requirements.txt - echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH - echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV + npm install -g mystmd thebe-core thebe thebe-lite - - if: ${{ steps.cache-html.outputs.cache-hit != 'true' }} - name: Build the book with TeachBooks + - name: Build HTML + working-directory: ./lectures run: | - set -o pipefail - # Build without preprocessing for PR preview - teachbooks build book/ > >(tee stdout.log) 2> >(tee stderr.log >&2) - set +o pipefail + myst build --html - - name: If build failed, attempt to restore from cache - if: failure() - id: attempt-restore - uses: actions/cache/restore@v4 + - name: Upload build output + uses: actions/upload-pages-artifact@v3 with: - key: none - path: "book/_build/html" - restore-keys: html-build-${{ github.head_ref }} - - - name: Check build output - run: | - echo "Build completed. Contents of book/_build/html/:" - ls -la book/_build/html/ || echo "No build output found" - echo "Checking for index.html:" - ls -la book/_build/html/index.html || echo "No index.html found" - - - name: Create build status summary - if: always() - run: | - if [ ${{ job.status }} == 'success' ]; then - echo "✅ **Build Status**: Success" >> build_summary.md - echo "Book built successfully from branch \`${{ github.head_ref }}\`" >> build_summary.md - else - echo "**Build Status**: Failed" >> build_summary.md - if [ -n "${{ steps.attempt-restore.outputs.cache-matched-key }}" ]; then - echo "Using cached version from previous successful build" >> build_summary.md - else - echo " No cached version available" >> build_summary.md - fi - fi - - if [ -s stderr.log ]; then - echo "" >> build_summary.md - echo " **Build Warnings/Errors**:" >> build_summary.md - echo '```' >> build_summary.md - cat stderr.log >> build_summary.md - echo '```' >> build_summary.md - fi + path: './lectures/_build/html' - - name: Deploy to Netlify - if: always() && hashFiles('book/_build/html/**') != '' + - name: Preview Deploy to Netlify uses: nwtgck/actions-netlify@v3 with: - publish-dir: 'book/_build/html/' + publish-dir: './lectures/_build/html' production-branch: main github-token: ${{ secrets.GITHUB_TOKEN }} - deploy-message: "Preview Deploy from ${{ github.head_ref }} (PR #${{ github.event.number }})" - alias: pr-${{ github.event.number }} - enable-pull-request-comment: true - enable-commit-comment: false - overwrites-pull-request-comment: true + deploy-message: "Preview Deploy from GitHub Actions" env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} - - - name: Comment build summary on PR - if: always() - uses: actions/github-script@v7 - with: - script: | - const fs = require('fs'); - let summary = ''; - try { - summary = fs.readFileSync('build_summary.md', 'utf8'); - } catch (error) { - summary = '📋 Build summary not available'; - } - - const body = `## 🚀 TeachBooks Build & Deploy Summary - - ${summary} - - --- -
- 📖 TeachBooks Configuration - - - **Branch**: \`${{ github.head_ref }}\` - - **Build Command**: \`teachbooks build book/\` - - **Preprocessing**: Disabled (PR preview) - - **Archive Banner**: Disabled (PR preview) - - **Cache**: ${{ steps.cache-html.outputs.cache-hit == 'true' && 'Hit ✅' || 'Miss ❌' }} - -
`; - - // Get existing comments - const { data: comments } = await github.rest.issues.listComments({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - }); - - // Find existing bot comment - const botComment = comments.find(comment => - comment.user.type === 'Bot' && - comment.body.includes('🚀 TeachBooks Build & Deploy Summary') - ); - - if (botComment) { - // Update existing comment - await github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: botComment.id, - body: body - }); - } else { - // Create new comment - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - body: body - }); - } diff --git a/.gitignore b/.gitignore index 991462c..cd85698 100644 --- a/.gitignore +++ b/.gitignore @@ -118,3 +118,4 @@ _output # build **/*/_build **/*/.teachbooks +_build/ diff --git a/book/_config.yml b/book/_config.yml deleted file mode 100644 index ea387ac..0000000 --- a/book/_config.yml +++ /dev/null @@ -1,83 +0,0 @@ -author: QuantEcon team - -execute: - execute_notebooks: "off" - -only_build_toc_files: true - -html: - favicon : "figures/favicon.ico" - baseurl : "https://quantecon.org/" - -sphinx: - config: - html_js_files: - - https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js - thebe_config: - use_thebe_lite: true - exclude_patterns: ["**/_*.yml", "**/*.md", "**/*.ipynb"] - html_theme_options: - logo: - text: QuantEcon Intro Lectures - image_light: figures/qe-logo.png - image_dark: figures/qe-logo.png - authors: - - name: Thomas J. Sargent - url: http://www.tomsargent.com/ - - name: John Stachurski - url: https://johnstachurski.net/ - header_organisation_url: https://quantecon.org - header_organisation: QuantEcon - repository_url: https://github.com/QuantEcon/lecture-python-advanced.myst - nb_repository_url: https://github.com/QuantEcon/lecture-python-advanced.notebooks - twitter: quantecon - twitter_logo_url: https://assets.quantecon.org/img/qe-twitter-logo.png - og_logo_url: https://assets.quantecon.org/img/qe-og-logo.png - description: This website presents a set of lectures on advanced quantitative economic modeling, designed and written by Thomas J. Sargent and John Stachurski. - keywords: Python, QuantEcon, Quantitative Economics, Economics, Sloan, Alfred P. Sloan Foundation, Tom J. Sargent, John Stachurski - analytics: - google_analytics_id: G-KZLV7PM9LL - launch_buttons: - thebe: true - #colab_url : https://colab.research.google.com - mathjax3_config: - tex: - macros: - "argmax": "arg\\,max" - "argmin": "arg\\,min" - "col": "col" - "Span": "span" - "epsilon": "\\varepsilon" - "EE": "\\mathbb{E}" - "PP": "\\mathbb{P}" - "RR": "\\mathbb{R}" - "NN": "\\mathbb{N}" - "ZZ": "\\mathbb{Z}" - "aA": "\\mathcal{A}" - "bB": "\\mathcal{B}" - "cC": "\\mathcal{C}" - "dD": "\\mathcal{D}" - "eE": "\\mathcal{E}" - "fF": "\\mathcal{F}" - "gG": "\\mathcal{G}" - "hH": "\\mathcal{H}" - html_show_copyright: false - html_last_updated_fmt: '%B %-d, %Y' - html_static_path: ["figures"] # add folders that contain files that need to be included, such as the location of the logo(s) - mathjax3_config: - chtml: { - mtextInheritFont: true # To typeset text within math prettier - } - extra_extensions: - - sphinx.ext.imgconverter - - jupyterbook_patches - - download_link_replacer - - sphinx.ext.extlinks - - sphinx_image_inverter - - sphinx_exercise - - sphinx_proof - - sphinx_tojupyter - - sphinx_reredirects - -bibtex_bibfiles: - - _static/quant-econ.bib diff --git a/book/_toc.yml b/book/_toc.yml deleted file mode 100644 index cc420c3..0000000 --- a/book/_toc.yml +++ /dev/null @@ -1,94 +0,0 @@ -format: jb-book -root: intro -parts: -- caption: Introduction - numbered: true - chapters: - - file: about -- caption: Economic Data - numbered: true - chapters: - - file: long_run_growth - - file: business_cycle - - file: inflation_history - - file: french_rev - - file: inequality -- caption: Foundations - numbered: true - chapters: - - file: intro_supply_demand - - file: linear_equations - - file: complex_and_trig - - file: geom_series -- caption: "Linear Dynamics: Finite Horizons" - numbered: true - chapters: - - file: pv - - file: cons_smooth - - file: tax_smooth - - file: equalizing_difference - - file: cagan_ree - - file: cagan_adaptive -- caption: "Linear Dynamics: Infinite Horizons" - numbered: true - chapters: - - file: eigen_I - - file: greek_square -- caption: Probability and Distributions - numbered: true - chapters: - - file: prob_dist - - file: lln_clt - - file: monte_carlo - - file: heavy_tails - - file: schelling -- caption: Nonlinear Dynamics - numbered: true - chapters: - - file: scalar_dynam - - file: solow - - file: cobweb - - file: olg - - file: commod_price -- caption: Monetary-Fiscal Policy Interactions - numbered: true - chapters: - - file: money_inflation - - file: unpleasant - - file: money_inflation_nonlinear - - file: laffer_adaptive -- caption: Stochastic Dynamics - numbered: true - chapters: - - file: ar1_processes - - file: markov_chains_I - - file: markov_chains_II - - file: time_series_with_matrices -- caption: Optimization - numbered: true - chapters: - - file: lp_intro - - file: short_path -- caption: Modeling in Higher Dimensions - numbered: true - chapters: - - file: eigen_II - - file: input_output - - file: lake_model - - file: networks -- caption: Markets and Competitive Equilibrium - numbered: true - chapters: - - file: supply_demand_multiple_goods - - file: supply_demand_heterogeneity -- caption: Estimation - numbered: true - chapters: - - file: simple_linear_regression - - file: mle -- caption: Other - numbered: true - chapters: - - file: troubleshooting - - file: zreferences - - file: status diff --git a/book/_admonition/wasm-compat.md b/lectures/_admonition/wasm-compat.md similarity index 100% rename from book/_admonition/wasm-compat.md rename to lectures/_admonition/wasm-compat.md diff --git a/book/_static/lecture_specific/cross_section/light_heavy_fig1.png b/lectures/_static/lecture_specific/cross_section/light_heavy_fig1.png similarity index 100% rename from book/_static/lecture_specific/cross_section/light_heavy_fig1.png rename to lectures/_static/lecture_specific/cross_section/light_heavy_fig1.png diff --git a/book/_static/lecture_specific/cross_section/rank_size_fig1.png b/lectures/_static/lecture_specific/cross_section/rank_size_fig1.png similarity index 100% rename from book/_static/lecture_specific/cross_section/rank_size_fig1.png rename to lectures/_static/lecture_specific/cross_section/rank_size_fig1.png diff --git a/book/_static/lecture_specific/inequality/data.ipynb b/lectures/_static/lecture_specific/inequality/data.ipynb similarity index 100% rename from book/_static/lecture_specific/inequality/data.ipynb rename to lectures/_static/lecture_specific/inequality/data.ipynb diff --git a/book/_static/lecture_specific/inequality/usa-gini-nwealth-tincome-lincome.csv b/lectures/_static/lecture_specific/inequality/usa-gini-nwealth-tincome-lincome.csv similarity index 100% rename from book/_static/lecture_specific/inequality/usa-gini-nwealth-tincome-lincome.csv rename to lectures/_static/lecture_specific/inequality/usa-gini-nwealth-tincome-lincome.csv diff --git a/book/_static/lecture_specific/lake_model/figures.ipynb b/lectures/_static/lecture_specific/lake_model/figures.ipynb similarity index 100% rename from book/_static/lecture_specific/lake_model/figures.ipynb rename to lectures/_static/lecture_specific/lake_model/figures.ipynb diff --git a/book/_static/lecture_specific/lake_model/lake_model_worker b/lectures/_static/lecture_specific/lake_model/lake_model_worker similarity index 100% rename from book/_static/lecture_specific/lake_model/lake_model_worker rename to lectures/_static/lecture_specific/lake_model/lake_model_worker diff --git a/book/_static/lecture_specific/lake_model/lake_model_worker.png b/lectures/_static/lecture_specific/lake_model/lake_model_worker.png similarity index 100% rename from book/_static/lecture_specific/lake_model/lake_model_worker.png rename to lectures/_static/lecture_specific/lake_model/lake_model_worker.png diff --git a/book/_static/lecture_specific/long_run_growth/tooze_ch1_graph.png b/lectures/_static/lecture_specific/long_run_growth/tooze_ch1_graph.png similarity index 100% rename from book/_static/lecture_specific/long_run_growth/tooze_ch1_graph.png rename to lectures/_static/lecture_specific/long_run_growth/tooze_ch1_graph.png diff --git a/book/_static/lecture_specific/markov_chains_I/Hamilton b/lectures/_static/lecture_specific/markov_chains_I/Hamilton similarity index 100% rename from book/_static/lecture_specific/markov_chains_I/Hamilton rename to lectures/_static/lecture_specific/markov_chains_I/Hamilton diff --git a/book/_static/lecture_specific/markov_chains_I/Hamilton.png b/lectures/_static/lecture_specific/markov_chains_I/Hamilton.png similarity index 100% rename from book/_static/lecture_specific/markov_chains_I/Hamilton.png rename to lectures/_static/lecture_specific/markov_chains_I/Hamilton.png diff --git a/book/_static/lecture_specific/markov_chains_I/Temple b/lectures/_static/lecture_specific/markov_chains_I/Temple similarity index 100% rename from book/_static/lecture_specific/markov_chains_I/Temple rename to lectures/_static/lecture_specific/markov_chains_I/Temple diff --git a/book/_static/lecture_specific/markov_chains_I/Temple.png b/lectures/_static/lecture_specific/markov_chains_I/Temple.png similarity index 100% rename from book/_static/lecture_specific/markov_chains_I/Temple.png rename to lectures/_static/lecture_specific/markov_chains_I/Temple.png diff --git a/book/_static/lecture_specific/markov_chains_I/figures.ipynb b/lectures/_static/lecture_specific/markov_chains_I/figures.ipynb similarity index 100% rename from book/_static/lecture_specific/markov_chains_I/figures.ipynb rename to lectures/_static/lecture_specific/markov_chains_I/figures.ipynb diff --git a/book/_static/lecture_specific/markov_chains_II/Irre_1 b/lectures/_static/lecture_specific/markov_chains_II/Irre_1 similarity index 100% rename from book/_static/lecture_specific/markov_chains_II/Irre_1 rename to lectures/_static/lecture_specific/markov_chains_II/Irre_1 diff --git a/book/_static/lecture_specific/markov_chains_II/Irre_1.png b/lectures/_static/lecture_specific/markov_chains_II/Irre_1.png similarity index 100% rename from book/_static/lecture_specific/markov_chains_II/Irre_1.png rename to lectures/_static/lecture_specific/markov_chains_II/Irre_1.png diff --git a/book/_static/lecture_specific/markov_chains_II/Irre_2 b/lectures/_static/lecture_specific/markov_chains_II/Irre_2 similarity index 100% rename from book/_static/lecture_specific/markov_chains_II/Irre_2 rename to lectures/_static/lecture_specific/markov_chains_II/Irre_2 diff --git a/book/_static/lecture_specific/markov_chains_II/Irre_2.png b/lectures/_static/lecture_specific/markov_chains_II/Irre_2.png similarity index 100% rename from book/_static/lecture_specific/markov_chains_II/Irre_2.png rename to lectures/_static/lecture_specific/markov_chains_II/Irre_2.png diff --git a/book/_static/lecture_specific/markov_chains_II/example4 b/lectures/_static/lecture_specific/markov_chains_II/example4 similarity index 100% rename from book/_static/lecture_specific/markov_chains_II/example4 rename to lectures/_static/lecture_specific/markov_chains_II/example4 diff --git a/book/_static/lecture_specific/markov_chains_II/example4.png b/lectures/_static/lecture_specific/markov_chains_II/example4.png similarity index 100% rename from book/_static/lecture_specific/markov_chains_II/example4.png rename to lectures/_static/lecture_specific/markov_chains_II/example4.png diff --git a/book/_static/lecture_specific/markov_chains_II/figures.ipynb b/lectures/_static/lecture_specific/markov_chains_II/figures.ipynb similarity index 100% rename from book/_static/lecture_specific/markov_chains_II/figures.ipynb rename to lectures/_static/lecture_specific/markov_chains_II/figures.ipynb diff --git a/book/_static/lecture_specific/networks/figures.ipynb b/lectures/_static/lecture_specific/networks/figures.ipynb similarity index 100% rename from book/_static/lecture_specific/networks/figures.ipynb rename to lectures/_static/lecture_specific/networks/figures.ipynb diff --git a/book/_static/lecture_specific/networks/mc b/lectures/_static/lecture_specific/networks/mc similarity index 100% rename from book/_static/lecture_specific/networks/mc rename to lectures/_static/lecture_specific/networks/mc diff --git a/book/_static/lecture_specific/networks/mc.png b/lectures/_static/lecture_specific/networks/mc.png similarity index 100% rename from book/_static/lecture_specific/networks/mc.png rename to lectures/_static/lecture_specific/networks/mc.png diff --git a/book/_static/lecture_specific/networks/poverty_trap_1 b/lectures/_static/lecture_specific/networks/poverty_trap_1 similarity index 100% rename from book/_static/lecture_specific/networks/poverty_trap_1 rename to lectures/_static/lecture_specific/networks/poverty_trap_1 diff --git a/book/_static/lecture_specific/networks/poverty_trap_1.png b/lectures/_static/lecture_specific/networks/poverty_trap_1.png similarity index 100% rename from book/_static/lecture_specific/networks/poverty_trap_1.png rename to lectures/_static/lecture_specific/networks/poverty_trap_1.png diff --git a/book/_static/lecture_specific/networks/poverty_trap_2 b/lectures/_static/lecture_specific/networks/poverty_trap_2 similarity index 100% rename from book/_static/lecture_specific/networks/poverty_trap_2 rename to lectures/_static/lecture_specific/networks/poverty_trap_2 diff --git a/book/_static/lecture_specific/networks/poverty_trap_2.png b/lectures/_static/lecture_specific/networks/poverty_trap_2.png similarity index 100% rename from book/_static/lecture_specific/networks/poverty_trap_2.png rename to lectures/_static/lecture_specific/networks/poverty_trap_2.png diff --git a/book/_static/lecture_specific/networks/properties b/lectures/_static/lecture_specific/networks/properties similarity index 100% rename from book/_static/lecture_specific/networks/properties rename to lectures/_static/lecture_specific/networks/properties diff --git a/book/_static/lecture_specific/networks/properties.png b/lectures/_static/lecture_specific/networks/properties.png similarity index 100% rename from book/_static/lecture_specific/networks/properties.png rename to lectures/_static/lecture_specific/networks/properties.png diff --git a/book/_static/lecture_specific/networks/weighted b/lectures/_static/lecture_specific/networks/weighted similarity index 100% rename from book/_static/lecture_specific/networks/weighted rename to lectures/_static/lecture_specific/networks/weighted diff --git a/book/_static/lecture_specific/networks/weighted.png b/lectures/_static/lecture_specific/networks/weighted.png similarity index 100% rename from book/_static/lecture_specific/networks/weighted.png rename to lectures/_static/lecture_specific/networks/weighted.png diff --git a/book/_static/lecture_specific/schelling/schelling_fig1.png b/lectures/_static/lecture_specific/schelling/schelling_fig1.png similarity index 100% rename from book/_static/lecture_specific/schelling/schelling_fig1.png rename to lectures/_static/lecture_specific/schelling/schelling_fig1.png diff --git a/book/_static/lecture_specific/schelling/schelling_fig2.png b/lectures/_static/lecture_specific/schelling/schelling_fig2.png similarity index 100% rename from book/_static/lecture_specific/schelling/schelling_fig2.png rename to lectures/_static/lecture_specific/schelling/schelling_fig2.png diff --git a/book/_static/lecture_specific/schelling/schelling_fig3.png b/lectures/_static/lecture_specific/schelling/schelling_fig3.png similarity index 100% rename from book/_static/lecture_specific/schelling/schelling_fig3.png rename to lectures/_static/lecture_specific/schelling/schelling_fig3.png diff --git a/book/_static/lecture_specific/schelling/schelling_fig4.png b/lectures/_static/lecture_specific/schelling/schelling_fig4.png similarity index 100% rename from book/_static/lecture_specific/schelling/schelling_fig4.png rename to lectures/_static/lecture_specific/schelling/schelling_fig4.png diff --git a/book/_static/lecture_specific/short_path/figures.ipynb b/lectures/_static/lecture_specific/short_path/figures.ipynb similarity index 100% rename from book/_static/lecture_specific/short_path/figures.ipynb rename to lectures/_static/lecture_specific/short_path/figures.ipynb diff --git a/book/_static/lecture_specific/short_path/graph.png b/lectures/_static/lecture_specific/short_path/graph.png similarity index 100% rename from book/_static/lecture_specific/short_path/graph.png rename to lectures/_static/lecture_specific/short_path/graph.png diff --git a/book/_static/lecture_specific/short_path/graph2.png b/lectures/_static/lecture_specific/short_path/graph2.png similarity index 100% rename from book/_static/lecture_specific/short_path/graph2.png rename to lectures/_static/lecture_specific/short_path/graph2.png diff --git a/book/_static/lecture_specific/short_path/graph3.png b/lectures/_static/lecture_specific/short_path/graph3.png similarity index 100% rename from book/_static/lecture_specific/short_path/graph3.png rename to lectures/_static/lecture_specific/short_path/graph3.png diff --git a/book/_static/lecture_specific/short_path/graph4.png b/lectures/_static/lecture_specific/short_path/graph4.png similarity index 100% rename from book/_static/lecture_specific/short_path/graph4.png rename to lectures/_static/lecture_specific/short_path/graph4.png diff --git a/book/_static/lecture_specific/simple_linear_regression/life-expectancy-vs-gdp-per-capita.csv b/lectures/_static/lecture_specific/simple_linear_regression/life-expectancy-vs-gdp-per-capita.csv similarity index 100% rename from book/_static/lecture_specific/simple_linear_regression/life-expectancy-vs-gdp-per-capita.csv rename to lectures/_static/lecture_specific/simple_linear_regression/life-expectancy-vs-gdp-per-capita.csv diff --git a/book/_static/lecture_specific/troubleshooting/launch.png b/lectures/_static/lecture_specific/troubleshooting/launch.png similarity index 100% rename from book/_static/lecture_specific/troubleshooting/launch.png rename to lectures/_static/lecture_specific/troubleshooting/launch.png diff --git a/book/_static/lectures-favicon.ico b/lectures/_static/lectures-favicon.ico similarity index 100% rename from book/_static/lectures-favicon.ico rename to lectures/_static/lectures-favicon.ico diff --git a/book/_static/qe-logo-large.png b/lectures/_static/qe-logo-large.png similarity index 100% rename from book/_static/qe-logo-large.png rename to lectures/_static/qe-logo-large.png diff --git a/book/_static/qe-logo.png b/lectures/_static/qe-logo.png similarity index 100% rename from book/_static/qe-logo.png rename to lectures/_static/qe-logo.png diff --git a/book/_static/quant-econ.bib b/lectures/_static/quant-econ.bib similarity index 100% rename from book/_static/quant-econ.bib rename to lectures/_static/quant-econ.bib diff --git a/book/_static/quantecon-logo-transparent.png b/lectures/_static/quantecon-logo-transparent.png similarity index 100% rename from book/_static/quantecon-logo-transparent.png rename to lectures/_static/quantecon-logo-transparent.png diff --git a/book/about.md b/lectures/about.md similarity index 100% rename from book/about.md rename to lectures/about.md diff --git a/book/ar1_processes.md b/lectures/ar1_processes.md similarity index 99% rename from book/ar1_processes.md rename to lectures/ar1_processes.md index 8c75184..df50660 100644 --- a/book/ar1_processes.md +++ b/lectures/ar1_processes.md @@ -400,7 +400,7 @@ Confirm this by simulation at a range of $k$ using the default parameters from t ``` -```{solution-start} ar1p_ex1 +```{solution} ar1p_ex1 :class: dropdown ``` @@ -440,7 +440,7 @@ ax.legend() plt.show() ``` -```{solution-end} +```{solution} ``` @@ -490,7 +490,7 @@ of these distributions?) ``` -```{solution-start} ar1p_ex2 +```{solution} ar1p_ex2 :class: dropdown ``` @@ -545,7 +545,7 @@ for α, β in parameter_pairs: We see that the kernel density estimator is effective when the underlying distribution is smooth but less so otherwise. -```{solution-end} +```{solution} ``` @@ -591,7 +591,7 @@ simulation based estimate of $\psi_{t+1}$ does converge to the theoretical distribution. ``` -```{solution-start} ar1p_ex3 +```{solution} ar1p_ex3 :class: dropdown ``` @@ -640,5 +640,5 @@ plt.show() The simulated distribution approximately coincides with the theoretical distribution, as predicted. -```{solution-end} +```{solution} ``` diff --git a/book/business_cycle.md b/lectures/business_cycle.md similarity index 99% rename from book/business_cycle.md rename to lectures/business_cycle.md index e3849b4..f0f51ff 100644 --- a/book/business_cycle.md +++ b/lectures/business_cycle.md @@ -13,9 +13,6 @@ kernelspec: # Business Cycles -```{include} _admonition/wasm-compat.md -``` - ## Overview In this lecture we review some empirical aspects of business cycles. diff --git a/book/cagan_adaptive.md b/lectures/cagan_adaptive.md similarity index 100% rename from book/cagan_adaptive.md rename to lectures/cagan_adaptive.md diff --git a/book/cagan_ree.md b/lectures/cagan_ree.md similarity index 100% rename from book/cagan_ree.md rename to lectures/cagan_ree.md diff --git a/book/cobweb.md b/lectures/cobweb.md similarity index 99% rename from book/cobweb.md rename to lectures/cobweb.md index 3bda73f..9d5c849 100644 --- a/book/cobweb.md +++ b/lectures/cobweb.md @@ -482,7 +482,7 @@ Show, in particular, that supply also cycles. ```{exercise-end} ``` -```{solution-start} cobweb_ex1 +```{solution} cobweb_ex1 :class: dropdown ``` @@ -521,7 +521,7 @@ m = Market() ts_plot_supply(m, 5, 15) ``` -```{solution-end} +```{solution} ``` ```{exercise-start} @@ -546,7 +546,7 @@ Simulate and plot the price dynamics for $\alpha \in \{0.1, 0.3, 0.5, 0.8\}$ whe ```{exercise-end} ``` -```{solution-start} cobweb_ex2 +```{solution} cobweb_ex2 :class: dropdown ``` @@ -594,5 +594,5 @@ ts_plot_price_blae(m, ts_length=20) ``` -```{solution-end} +```{solution} ``` \ No newline at end of file diff --git a/book/commod_price.md b/lectures/commod_price.md similarity index 99% rename from book/commod_price.md rename to lectures/commod_price.md index c4392e6..48fb38d 100644 --- a/book/commod_price.md +++ b/lectures/commod_price.md @@ -14,9 +14,6 @@ kernelspec: # Commodity Prices -```{include} _admonition/wasm-compat.md -``` - ## Outline For more than half of all countries around the globe, [commodities](https://en.wikipedia.org/wiki/Commodity) account for [the majority of total exports](https://unctad.org/publication/commodities-and-development-report-2019). diff --git a/book/complex_and_trig.md b/lectures/complex_and_trig.md similarity index 99% rename from book/complex_and_trig.md rename to lectures/complex_and_trig.md index 7f40497..cda794a 100644 --- a/book/complex_and_trig.md +++ b/lectures/complex_and_trig.md @@ -499,7 +499,7 @@ $$ $$ ``` -```{solution-start} complex_ex1 +```{solution} complex_ex1 :class: dropdown ``` @@ -524,5 +524,5 @@ from -π to π is:') integrate(sin(ω)**2, (ω, -pi, pi)) ``` -```{solution-end} +```{solution} ``` diff --git a/book/cons_smooth.md b/lectures/cons_smooth.md similarity index 100% rename from book/cons_smooth.md rename to lectures/cons_smooth.md diff --git a/book/datasets/GDP_per_capita_world_bank.csv b/lectures/datasets/GDP_per_capita_world_bank.csv similarity index 100% rename from book/datasets/GDP_per_capita_world_bank.csv rename to lectures/datasets/GDP_per_capita_world_bank.csv diff --git a/book/datasets/Metadata_Country_API_NY.GDP.PCAP.CD_DS2_en_csv_v2_4770417.csv b/lectures/datasets/Metadata_Country_API_NY.GDP.PCAP.CD_DS2_en_csv_v2_4770417.csv similarity index 100% rename from book/datasets/Metadata_Country_API_NY.GDP.PCAP.CD_DS2_en_csv_v2_4770417.csv rename to lectures/datasets/Metadata_Country_API_NY.GDP.PCAP.CD_DS2_en_csv_v2_4770417.csv diff --git a/book/datasets/assignat.xlsx b/lectures/datasets/assignat.xlsx similarity index 100% rename from book/datasets/assignat.xlsx rename to lectures/datasets/assignat.xlsx diff --git a/book/datasets/caron.npy b/lectures/datasets/caron.npy similarity index 100% rename from book/datasets/caron.npy rename to lectures/datasets/caron.npy diff --git a/book/datasets/chapter_3.xlsx b/lectures/datasets/chapter_3.xlsx similarity index 100% rename from book/datasets/chapter_3.xlsx rename to lectures/datasets/chapter_3.xlsx diff --git a/book/datasets/dette.xlsx b/lectures/datasets/dette.xlsx similarity index 100% rename from book/datasets/dette.xlsx rename to lectures/datasets/dette.xlsx diff --git a/book/datasets/fig_3.ods b/lectures/datasets/fig_3.ods similarity index 100% rename from book/datasets/fig_3.ods rename to lectures/datasets/fig_3.ods diff --git a/book/datasets/fig_3.xlsx b/lectures/datasets/fig_3.xlsx similarity index 100% rename from book/datasets/fig_3.xlsx rename to lectures/datasets/fig_3.xlsx diff --git a/book/datasets/longprices.xls b/lectures/datasets/longprices.xls similarity index 100% rename from book/datasets/longprices.xls rename to lectures/datasets/longprices.xls diff --git a/book/datasets/mpd2020.xlsx b/lectures/datasets/mpd2020.xlsx similarity index 100% rename from book/datasets/mpd2020.xlsx rename to lectures/datasets/mpd2020.xlsx diff --git a/book/datasets/nom_balances.npy b/lectures/datasets/nom_balances.npy similarity index 100% rename from book/datasets/nom_balances.npy rename to lectures/datasets/nom_balances.npy diff --git a/book/eigen_I.md b/lectures/eigen_I.md similarity index 99% rename from book/eigen_I.md rename to lectures/eigen_I.md index 9cd6835..2704d5f 100644 --- a/book/eigen_I.md +++ b/lectures/eigen_I.md @@ -988,7 +988,7 @@ In this exercise, first implement the power iteration method and use it to find Then visualize the convergence. ``` -```{solution-start} eig1_ex1 +```{solution} eig1_ex1 :class: dropdown ``` @@ -1086,7 +1086,7 @@ plt.show() +++ {"user_expressions": []} -```{solution-end} +```{solution} ``` ```{exercise} @@ -1100,7 +1100,7 @@ Try to compute the trajectory of $v$ after being transformed by $A$ for $n=4$ it ``` -```{solution-start} eig1_ex2 +```{solution} eig1_ex2 :class: dropdown ``` @@ -1180,7 +1180,7 @@ Specifically, the eigenvector with the largest eigenvalue is the direction in wh We will see more intriguing examples in the following exercise. -```{solution-end} +```{solution} ``` ```{exercise} @@ -1193,7 +1193,7 @@ Use the visualization in the previous exercise to explain the trajectory of the ``` -```{solution-start} eig1_ex3 +```{solution} eig1_ex3 :class: dropdown ``` @@ -1340,5 +1340,5 @@ plt.show() +++ {"user_expressions": []} -```{solution-end} +```{solution} ``` diff --git a/book/eigen_II.md b/lectures/eigen_II.md similarity index 99% rename from book/eigen_II.md rename to lectures/eigen_II.md index c9bb9eb..f1155df 100644 --- a/book/eigen_II.md +++ b/lectures/eigen_II.md @@ -536,7 +536,7 @@ The solution $x^{*}$ is given by the equation $x^{*} = (I-A)^{-1} d$ ```{exercise-end} ``` -```{solution-start} eig_ex1 +```{solution} eig_ex1 :class: dropdown ``` @@ -565,5 +565,5 @@ x_star = B_inv @ d print(x_star) ``` -```{solution-end} +```{solution} ``` diff --git a/book/equalizing_difference.md b/lectures/equalizing_difference.md similarity index 100% rename from book/equalizing_difference.md rename to lectures/equalizing_difference.md diff --git a/book/figures/favicon.ico b/lectures/figures/favicon.ico similarity index 100% rename from book/figures/favicon.ico rename to lectures/figures/favicon.ico diff --git a/book/figures/qe-logo.png b/lectures/figures/qe-logo.png similarity index 100% rename from book/figures/qe-logo.png rename to lectures/figures/qe-logo.png diff --git a/book/french_rev.md b/lectures/french_rev.md similarity index 100% rename from book/french_rev.md rename to lectures/french_rev.md diff --git a/book/geom_series.md b/lectures/geom_series.md similarity index 100% rename from book/geom_series.md rename to lectures/geom_series.md diff --git a/book/graph.txt b/lectures/graph.txt similarity index 100% rename from book/graph.txt rename to lectures/graph.txt diff --git a/book/greek_square.md b/lectures/greek_square.md similarity index 99% rename from book/greek_square.md rename to lectures/greek_square.md index 9c6a532..e156311 100644 --- a/book/greek_square.md +++ b/lectures/greek_square.md @@ -741,7 +741,7 @@ compute the matrix $A$. ```{exercise-end} ``` -```{solution-start} greek_square_ex_a +```{solution} greek_square_ex_a :class: dropdown ``` @@ -796,5 +796,5 @@ print(f'\nEigenvalues:\n{eigenvalues}') print(f'\nEigenvectors:\n{eigenvectors}') ``` -```{solution-end} +```{solution} ``` diff --git a/book/heavy_tails.md b/lectures/heavy_tails.md similarity index 99% rename from book/heavy_tails.md rename to lectures/heavy_tails.md index 98dce9d..fe64ce2 100644 --- a/book/heavy_tails.md +++ b/lectures/heavy_tails.md @@ -14,9 +14,6 @@ kernelspec: (heavy_tail)= # Heavy-Tailed Distributions -```{include} _admonition/wasm-compat.md -``` - In addition to what's in Anaconda, this lecture will need the following libraries: ```{code-cell} ipython3 @@ -521,7 +518,7 @@ This function goes to zero as $x \to \infty$, but much slower than $G_E$. Show how the CCDF of the standard Pareto distribution can be derived from the CCDF of the exponential distribution. ``` -```{solution-start} ht_ex_x1 +```{solution} ht_ex_x1 :class: dropdown ``` Letting $G_E$ and $G_P$ be defined as above, letting $X$ be exponentially @@ -537,7 +534,7 @@ $$ & = y^{-\alpha} \end{aligned} $$ -```{solution-end} +```{solution} ``` Here's a plot that illustrates how $G_E$ goes to zero faster than $G_P$. @@ -1168,7 +1165,7 @@ Prove: If $X$ has a Pareto tail with tail index $\alpha$, then $\mathbb E[X^r] = \infty$ for all $r \geq \alpha$. ``` -```{solution-start} ht_ex2 +```{solution} ht_ex2 :class: dropdown ``` @@ -1195,7 +1192,7 @@ We know that $\int_{\bar x}^\infty x^{r-\alpha-1} dx = \infty$ whenever $r - \al Since $r \geq \alpha$, we have $\mathbb E X^r = \infty$. -```{solution-end} +```{solution} ``` @@ -1212,7 +1209,7 @@ Use `np.random.seed(11)` to set the seed. ``` -```{solution-start} ht_ex3 +```{solution} ht_ex3 :class: dropdown ``` @@ -1238,7 +1235,7 @@ plt.subplots_adjust(hspace=0.4) plt.show() ``` -```{solution-end} +```{solution} ``` @@ -1297,7 +1294,7 @@ try to track individual firms given the current distribution. We will discuss firm dynamics in later lectures.) ``` -```{solution-start} ht_ex5 +```{solution} ht_ex5 :class: dropdown ``` @@ -1407,7 +1404,7 @@ tax_rev_lognorm.mean(), tax_rev_lognorm.std() Looking at the output of the code, our main conclusion is that the Pareto assumption leads to a lower mean and greater dispersion. -```{solution-end} +```{solution} ``` ```{exercise} @@ -1427,7 +1424,7 @@ $X_1$. ``` -```{solution-start} ht_ex_cauchy +```{solution} ht_ex_cauchy :class: dropdown ``` @@ -1449,5 +1446,5 @@ In view of {eq}`lln_cch`, this is just $e^{-|t|}$. Thus, in the case of the Cauchy distribution, the sample mean itself has the very same Cauchy distribution, regardless of $n$! -```{solution-end} +```{solution} ``` diff --git a/book/inequality.md b/lectures/inequality.md similarity index 99% rename from book/inequality.md rename to lectures/inequality.md index 674c90f..767891d 100644 --- a/book/inequality.md +++ b/lectures/inequality.md @@ -13,9 +13,6 @@ kernelspec: # Income and Wealth Inequality -```{include} _admonition/wasm-compat.md -``` - ## Overview In the lecture {doc}`long_run_growth` we studied how GDP per capita has changed @@ -908,7 +905,7 @@ Confirm that higher variance generates more dispersion in the sample, and hence greater inequality. ``` -```{solution-start} inequality_ex1 +```{solution} inequality_ex1 :class: dropdown ``` @@ -994,7 +991,7 @@ plt.legend() plt.show() ``` -```{solution-end} +```{solution} ``` @@ -1009,7 +1006,7 @@ Plot the top shares generated from Lorenz curve and the top shares approximated ``` -```{solution-start} inequality_ex2 +```{solution} inequality_ex2 :class: dropdown ``` @@ -1048,7 +1045,7 @@ ax.legend() plt.show() ``` -```{solution-end} +```{solution} ``` ```{exercise} @@ -1065,7 +1062,7 @@ Re-write the function `gini_coefficient` using `numpy` and vectorized code. You can compare the output of this new function with the one above, and note the speed differences. ``` -```{solution-start} inequality_ex3 +```{solution} inequality_ex3 :class: dropdown ``` @@ -1137,5 +1134,5 @@ This gives us the Gini coefficients for these five households. gini_coefficients ``` -```{solution-end} +```{solution} ``` diff --git a/book/inflation_history.md b/lectures/inflation_history.md similarity index 99% rename from book/inflation_history.md rename to lectures/inflation_history.md index 1905ad2..c58c081 100644 --- a/book/inflation_history.md +++ b/lectures/inflation_history.md @@ -26,7 +26,7 @@ The `xlrd` package is used by `pandas` to perform operations on Excel files. ``` - + We can then import the Python modules we will use. @@ -280,7 +280,7 @@ def process_df(df): df = df[~df.index.duplicated(keep='first')] # Convert attribute values to numeric - df = df.applymap(lambda x: float(x) \ + df = df.map(lambda x: float(x) \ if x != '—' else np.nan) # Finally, we only focus on data between 1919 and 1925 @@ -383,7 +383,7 @@ for i in range(4): # Apply process_entry on the selected sheet sheet_list = [ pd.read_excel(xls, 'Table3.' + str(ind), - header=1).iloc[:row].applymap(process_entry) + header=1).iloc[:row].map(process_entry) for ind, row in zip(indices, rows)] sheet_list = [process_df(df) for df in sheet_list] diff --git a/book/input_output.md b/lectures/input_output.md similarity index 99% rename from book/input_output.md rename to lectures/input_output.md index 6851bca..3e5b9ad 100644 --- a/book/input_output.md +++ b/lectures/input_output.md @@ -13,9 +13,6 @@ kernelspec: # Input-Output Models -```{include} _admonition/wasm-compat.md -``` - ## Overview This lecture requires the following imports and installs before we proceed. @@ -647,7 +644,7 @@ where $z_0$ is a vector of labor services used in each industry. ```{exercise-end} ``` -```{solution-start} io_ex1 +```{solution} io_ex1 :class: dropdown ``` For each $i = 0,1,2$ and $j = 1,2$ @@ -656,7 +653,7 @@ $$ a_{ij} = \frac{z_{ij}}{x_j} $$ -```{solution-end} +```{solution} ``` ```{exercise-start} @@ -668,7 +665,7 @@ Derive the production possibility frontier for the economy characterized in the ```{exercise-end} ``` -```{solution-start} io_ex2 +```{solution} io_ex2 :class: dropdown ``` @@ -697,5 +694,5 @@ $$ 0.17 d_1 + 0.69 d_2 = 50 $$ -```{solution-end} +```{solution} ``` diff --git a/book/intro.md b/lectures/intro.md similarity index 59% rename from book/intro.md rename to lectures/intro.md index 651d815..d0bfe9a 100644 --- a/book/intro.md +++ b/lectures/intro.md @@ -9,9 +9,7 @@ kernelspec: name: python3 --- -# A First Course in Quantitative Economics with Python (WASM backend) - -Authored by [Thomas J. Sargent](http://www.tomsargent.com/) and [John Stachurski](https://johnstachurski.net/). +# A First Course in Quantitative Economics with Python This lecture series provides an introduction to quantitative economics using Python. diff --git a/book/intro_supply_demand.md b/lectures/intro_supply_demand.md similarity index 99% rename from book/intro_supply_demand.md rename to lectures/intro_supply_demand.md index 575a4cc..11a8f31 100644 --- a/book/intro_supply_demand.md +++ b/lectures/intro_supply_demand.md @@ -728,7 +728,7 @@ Then plot the inverse demand and supply curves $i_d$ and $i_s$. ``` -```{solution-start} isd_ex1 +```{solution} isd_ex1 :class: dropdown ``` @@ -763,7 +763,7 @@ ax.set_ylabel('price') plt.show() ``` -```{solution-end} +```{solution} ``` @@ -804,7 +804,7 @@ Plot welfare as a function of $q$. ``` -```{solution-start} isd_ex2 +```{solution} isd_ex2 :class: dropdown ``` @@ -836,7 +836,7 @@ ax.set_xlabel('quantity') plt.show() ``` -```{solution-end} +```{solution} ``` @@ -857,7 +857,7 @@ is a useful resource to find out more. ```` -```{solution-start} isd_ex3 +```{solution} isd_ex3 :class: dropdown ``` @@ -876,7 +876,7 @@ maximizing_q = result.x print(f"{maximizing_q: .5f}") ``` -```{solution-end} +```{solution} ``` @@ -910,7 +910,7 @@ price, in line with the first fundamental welfare theorem. ```` -```{solution-start} isd_ex4 +```{solution} isd_ex4 :class: dropdown ``` @@ -924,5 +924,5 @@ equilibrium_q = newton(excess_demand, 0.99) print(f"{equilibrium_q: .5f}") ``` -```{solution-end} +```{solution} ``` diff --git a/book/laffer_adaptive.md b/lectures/laffer_adaptive.md similarity index 100% rename from book/laffer_adaptive.md rename to lectures/laffer_adaptive.md diff --git a/book/lake_model.md b/lectures/lake_model.md similarity index 99% rename from book/lake_model.md rename to lectures/lake_model.md index f70da94..9f3967d 100644 --- a/book/lake_model.md +++ b/lectures/lake_model.md @@ -537,7 +537,7 @@ shifts in the unemployment-employment space. ```{exercise-end} ``` -```{solution-start} lake_model_ex1 +```{solution} lake_model_ex1 :class: dropdown ``` @@ -566,5 +566,5 @@ ax.legend(loc='best') plt.show() ``` -```{solution-end} +```{solution} ``` diff --git a/book/linear_equations.md b/lectures/linear_equations.md similarity index 99% rename from book/linear_equations.md rename to lectures/linear_equations.md index 4b9ccb0..328a2d6 100644 --- a/book/linear_equations.md +++ b/lectures/linear_equations.md @@ -1159,7 +1159,7 @@ Equilibrium holds when supply equals demand, i.e, $q_0^d = q_0^s$, $q_1^d = q_1^ ```{exercise-end} ``` -```{solution-start} lin_eqs_ex1 +```{solution} lin_eqs_ex1 :class: dropdown ``` @@ -1235,7 +1235,7 @@ $$ p_0 = 4.6925, \; p_1 = 7.0625 \;\; \text{and} \;\; p_2 = 7.675 $$ -```{solution-end} +```{solution} ``` ```{exercise-start} @@ -1323,7 +1323,7 @@ We will thus try to find the best approximate solution for $x$. ```{exercise-end} ``` -```{solution-start} lin_eqs_ex2 +```{solution} lin_eqs_ex2 :class: dropdown ``` @@ -1378,7 +1378,7 @@ plt.legend() plt.show() ``` -```{solution-end} +```{solution} ``` diff --git a/book/lln_clt.md b/lectures/lln_clt.md similarity index 99% rename from book/lln_clt.md rename to lectures/lln_clt.md index 6a9227b..2cde183 100644 --- a/book/lln_clt.md +++ b/lectures/lln_clt.md @@ -517,7 +517,7 @@ Repeat the simulation [above](sim_one) with the [Beta distribution](https://en.w You can choose any $\alpha > 0$ and $\beta > 0$. ``` -```{solution-start} lln_ex1 +```{solution} lln_ex1 :class: dropdown ``` @@ -549,7 +549,7 @@ ax.legend() plt.show() ``` -```{solution-end} +```{solution} ``` ````{exercise} @@ -570,7 +570,7 @@ print(X) Explain why this provides a random variable $X$ with the right distribution. ```` -```{solution-start} lln_ex2 +```{solution} lln_ex2 :class: dropdown ``` @@ -586,7 +586,7 @@ $$ This means that $X = \mathbf 1\{U < p\}$ has the right distribution. -```{solution-end} +```{solution} ``` @@ -624,7 +624,7 @@ mean to the population mean still occurs. ``` -```{solution-start} lln_ex3 +```{solution} lln_ex3 :class: dropdown ``` @@ -706,5 +706,5 @@ plt.show() We see the convergence of $\bar x$ around $\mu$ even when the independence assumption is violated. -```{solution-end} +```{solution} ``` diff --git a/book/long_run_growth.md b/lectures/long_run_growth.md similarity index 100% rename from book/long_run_growth.md rename to lectures/long_run_growth.md diff --git a/book/lp_intro.md b/lectures/lp_intro.md similarity index 99% rename from book/lp_intro.md rename to lectures/lp_intro.md index e887da8..91c908c 100644 --- a/book/lp_intro.md +++ b/lectures/lp_intro.md @@ -12,9 +12,6 @@ kernelspec: (lp_intro)= # Linear Programming -```{include} _admonition/wasm-compat.md -``` - In this lecture, we will need the following library. Install [ortools](https://developers.google.com/optimization) using `pip`. ```{code-cell} ipython3 @@ -613,7 +610,7 @@ Implement a new extended solution for the Problem 1 where in the factory owner d ``` -```{solution-start} lp_intro_ex1 +```{solution} lp_intro_ex1 :class: dropdown ``` @@ -668,7 +665,7 @@ else: print('The problem does not have an optimal solution.') ``` -```{solution-end} +```{solution} ``` ```{exercise-start} @@ -690,7 +687,7 @@ Find the number of units of $A$ and product $B$ that he should manufacture in or ``` -```{solution-start} lp_intro_ex2 +```{solution} lp_intro_ex2 :class: dropdown ``` @@ -744,5 +741,5 @@ else: print('The problem does not have an optimal solution.') ``` -```{solution-end} +```{solution} ``` diff --git a/book/markov_chains_I.md b/lectures/markov_chains_I.md similarity index 99% rename from book/markov_chains_I.md rename to lectures/markov_chains_I.md index 7b042ce..a02da22 100644 --- a/book/markov_chains_I.md +++ b/lectures/markov_chains_I.md @@ -1096,7 +1096,7 @@ In this exercise, Compare your solution to the paper. ``` -```{solution-start} mc1_ex_1 +```{solution} mc1_ex_1 :class: dropdown ``` @@ -1135,7 +1135,7 @@ mc = qe.MarkovChain(P) ψ_star ``` -```{solution-end} +```{solution} ``` ````{exercise} @@ -1160,7 +1160,7 @@ In this exercise, 3. change the initial distribution to P(DG) = 1, while all other states have a probability of 0 ```` -```{solution-start} mc1_ex_2 +```{solution} mc1_ex_2 :class: dropdown ``` @@ -1212,7 +1212,7 @@ for idx in range(2): plt.show() ``` -```{solution-end} +```{solution} ``` ```{exercise} @@ -1222,7 +1222,7 @@ power $P^k$ for all $k \in \mathbb N$. ``` -```{solution-start} mc1_ex_3 +```{solution} mc1_ex_3 :class: dropdown ``` @@ -1244,5 +1244,5 @@ Therefore $P^{k+1} \mathbf 1 = P P^k \mathbf 1 = P \mathbf 1 = \mathbf 1$ The proof is done. -```{solution-end} +```{solution} ``` diff --git a/book/markov_chains_II.md b/lectures/markov_chains_II.md similarity index 99% rename from book/markov_chains_II.md rename to lectures/markov_chains_II.md index f8c2c29..305001f 100644 --- a/book/markov_chains_II.md +++ b/lectures/markov_chains_II.md @@ -447,7 +447,7 @@ codes_B = ('1','2','3','4','5','6','7','8') ```` -```{solution-start} mc_ex1 +```{solution} mc_ex1 :class: dropdown ``` Part 1: @@ -502,7 +502,7 @@ plt.show() Note that the fraction of time spent at each state converges to the probability assigned to that state by the stationary distribution. -```{solution-end} +```{solution} ``` @@ -544,7 +544,7 @@ $(0, 1)$. The result should be similar to the plot we plotted [here](ergo) ``` -```{solution-start} mc_ex2 +```{solution} mc_ex2 :class: dropdown ``` @@ -581,7 +581,7 @@ ax.legend() plt.show() ``` -```{solution-end} +```{solution} ``` ```{exercise} @@ -600,7 +600,7 @@ Based on this claim, write a function to test irreducibility. ``` -```{solution-start} mc_ex3 +```{solution} mc_ex3 :class: dropdown ``` @@ -630,5 +630,5 @@ for P in (P1, P2, P3): print(f'{P}: {result(P)}') ``` -```{solution-end} +```{solution} ``` diff --git a/book/mle.md b/lectures/mle.md similarity index 99% rename from book/mle.md rename to lectures/mle.md index bc4ce29..2a51e1f 100644 --- a/book/mle.md +++ b/lectures/mle.md @@ -469,7 +469,7 @@ $$ ```{exercise-end} ``` -```{solution-start} mle_ex1 +```{solution} mle_ex1 :class: dropdown ``` @@ -484,7 +484,7 @@ tr_expo = total_revenue(dist_exp) tr_expo ``` -```{solution-end} +```{solution} ``` ```{exercise-start} @@ -496,7 +496,7 @@ Plot the exponential distribution against the sample and check if it is a good f ```{exercise-end} ``` -```{solution-start} mle_ex2 +```{solution} mle_ex2 :class: dropdown ``` @@ -513,5 +513,5 @@ plt.show() Clearly, this distribution is not a good fit for our data. -```{solution-end} +```{solution} ``` diff --git a/book/money_inflation.md b/lectures/money_inflation.md similarity index 100% rename from book/money_inflation.md rename to lectures/money_inflation.md diff --git a/book/money_inflation_nonlinear.md b/lectures/money_inflation_nonlinear.md similarity index 100% rename from book/money_inflation_nonlinear.md rename to lectures/money_inflation_nonlinear.md diff --git a/book/monte_carlo.md b/lectures/monte_carlo.md similarity index 99% rename from book/monte_carlo.md rename to lectures/monte_carlo.md index 2797dd9..1657871 100644 --- a/book/monte_carlo.md +++ b/lectures/monte_carlo.md @@ -611,7 +611,7 @@ But this is problematic because Python loops are slow. Your task is to write a faster version of this code using NumPy. ``` -```{solution-start} monte_carlo_ex1 +```{solution} monte_carlo_ex1 :class: dropdown ``` @@ -655,7 +655,7 @@ compute_call_price(M=500_000) -```{solution-end} +```{solution} ``` ```{exercise} @@ -670,7 +670,7 @@ Note that the option does not reactivate if the spot price falls below \$120 aga Use the dynamics defined in {eq}`s_mc_dyms` to price the European call option. ``` -```{solution-start} monte_carlo_ex2 +```{solution} monte_carlo_ex2 :class: dropdown ``` @@ -760,5 +760,5 @@ def compute_call_price_with_barrier_vector(β=default_β, %time compute_call_price_with_barrier_vector() ``` -```{solution-end} +```{solution} ``` diff --git a/lectures/myst.yml b/lectures/myst.yml new file mode 100644 index 0000000..d7af169 --- /dev/null +++ b/lectures/myst.yml @@ -0,0 +1,120 @@ +version: 1 +project: + title: A First Course in Quantitative Economics with Python - WASM + authors: + - name: Thomas J. Sargent + affiliations: + - Professor of Economics, New York University. + - Senior Fellow, Hoover Institution, Stanford, CA. + url: http://www.tomsargent.com + - name: John Stachurski + affiliations: + - Professor, Research School of Economics, ANU. + - Instructor for Ph.D. Advanced Macroeconomics, University of Minnesota. + url: https://johnstachurski.net + email: john.stachurski@gmail.com + github: https://github.com/QuantEcon/project.lecture-wasm + + # Thebe configuration + # thebe: + # lite: true + + jupyter: + lite: true + # contents: + # - name: pyodide + # path: . + # settings: + # "@jupyterlite/pyodide-kernel-extension:kernel": + # pipliteUrls: "https://unpkg.com/@jupyterlite/pyodide-kernel@0.0.7/pypi/all.json" + # pyodideUrl: "https://cdn.jsdelivr.net/pyodide/v0.24.1/full/" + # pipliteWheelUrl: "https://unpkg.com/@jupyterlite/pyodide-kernel@0.0.7/pypi/piplite-0.0.7-py3-none-any.whl" + # enableMemoryStorage: true + # settingsStorageDrivers: + # - memory + # - localStorage + toc: + - file: intro.md + - title: Economic Data + children: + - file: long_run_growth + - file: business_cycle + - file: inflation_history + - file: french_rev + - file: inequality + - title: Foundations + children: + - file: intro_supply_demand + - file: linear_equations + - file: complex_and_trig + - file: geom_series + - title: "Linear Dynamics: Finite Horizons" + children: + - file: pv + - file: cons_smooth + - file: tax_smooth + - file: equalizing_difference + - file: cagan_ree + - file: cagan_adaptive + - title: "Linear Dynamics: Infinite Horizons" + children: + - file: eigen_I + - file: greek_square + - title: Probability and Distributions + children: + - file: prob_dist + - file: lln_clt + - file: monte_carlo + - file: heavy_tails + - file: schelling + - title: Nonlinear Dynamics + children: + - file: scalar_dynam + - file: solow + - file: cobweb + - file: olg + - file: commod_price + - title: Monetary-Fiscal Policy Interactions + children: + - file: money_inflation + - file: unpleasant + - file: money_inflation_nonlinear + - file: laffer_adaptive + - title: Stochastic Dynamics + children: + - file: ar1_processes + - file: markov_chains_I + - file: markov_chains_II + - file: time_series_with_matrices + - title: Optimization + children: + - file: lp_intro + - file: short_path + - title: Modeling in Higher Dimensions + children: + - file: eigen_II + - file: input_output + - file: lake_model + - file: networks + - title: Markets and Competitive Equilibrium + children: + - file: supply_demand_multiple_goods + - file: supply_demand_heterogeneity + - title: Estimation + children: + - file: simple_linear_regression + - file: mle + - title: Other + children: + - file: troubleshooting + - file: zreferences + - file: status + numbering: + titles: true + headings: true + heading_1: false + figure: + template: Fig. %s + +site: + template: https://github.com/QuantEcon/quantecon-theme/archive/refs/heads/main.zip diff --git a/book/networks.md b/lectures/networks.md similarity index 99% rename from book/networks.md rename to lectures/networks.md index 628693e..9e0e5ad 100644 --- a/book/networks.md +++ b/lectures/networks.md @@ -1166,7 +1166,7 @@ Show that $\sim$ is an [equivalence relation](https://en.wikipedia.org/wiki/Equi ```{exercise-end} ``` -```{solution-start} networks_ex1 +```{solution} networks_ex1 :class: dropdown ``` @@ -1193,7 +1193,7 @@ Thus, we can conclude $u \rightarrow v \rightarrow w$ and $w \rightarrow v \righ Which means $u \sim w$. -```{solution-end} +```{solution} ``` ```{exercise-start} @@ -1222,7 +1222,7 @@ $$ ```{exercise-end} ``` -```{solution-start} networks_ex2 +```{solution} networks_ex2 :class: dropdown ``` @@ -1268,7 +1268,7 @@ for i in range(n): print(i+1, e[i]) ``` -```{solution-end} +```{solution} ``` ```{exercise-start} @@ -1292,7 +1292,7 @@ Consider the graph in {ref}`networks_ex2` and use this function to check if ```{exercise-end} ``` -```{solution-start} networks_ex3 +```{solution} networks_ex3 :class: dropdown ``` @@ -1332,5 +1332,5 @@ is_accessible(G, 2, 1) is_accessible(G, 3, 6) ``` -```{solution-end} +```{solution} ``` diff --git a/book/olg.md b/lectures/olg.md similarity index 99% rename from book/olg.md rename to lectures/olg.md index 0794b2c..2493a49 100644 --- a/book/olg.md +++ b/lectures/olg.md @@ -661,7 +661,7 @@ Visualize the dynamics using a 45-degree diagram. ``` -```{solution-start} olg_ex1 +```{solution} olg_ex1 :class: dropdown ``` @@ -732,7 +732,7 @@ ax.set_ylabel('$k_{t+1}$', fontsize=12) plt.show() ``` -```{solution-end} +```{solution} ``` @@ -758,7 +758,7 @@ Instead, we solve for $k^*$ using Newton's method. ``` -```{solution-start} olg_ex2 +```{solution} olg_ex2 :class: dropdown ``` @@ -792,7 +792,7 @@ k_star = optimize.newton(h, 0.2, args=(model,)) print(f"k_star = {k_star}") ``` -```{solution-end} +```{solution} ``` @@ -809,7 +809,7 @@ Use initial conditions for $k_0$ of $0.001, 1.2, 2.6$ and time series length 10. ``` -```{solution-start} olg_ex3 +```{solution} olg_ex3 :class: dropdown ``` @@ -849,5 +849,5 @@ def simulate_ts(model, k0_values, ts_length): simulate_ts(model, k0, ts_length) ``` -```{solution-end} +```{solution} ``` diff --git a/book/plot-for-tom-gdp-1970-to-2018.png b/lectures/plot-for-tom-gdp-1970-to-2018.png similarity index 100% rename from book/plot-for-tom-gdp-1970-to-2018.png rename to lectures/plot-for-tom-gdp-1970-to-2018.png diff --git a/book/prob_dist.md b/lectures/prob_dist.md similarity index 99% rename from book/prob_dist.md rename to lectures/prob_dist.md index 2c52a30..662b930 100644 --- a/book/prob_dist.md +++ b/lectures/prob_dist.md @@ -13,9 +13,6 @@ kernelspec: # Distributions and Probabilities -```{include} _admonition/wasm-compat.md -``` - ```{index} single: Distributions and Probabilities ``` @@ -268,7 +265,7 @@ plt.show() Using `u.pmf`, check that our definition of the CDF given above calculates the same function as `u.cdf`. ``` -```{solution-start} prob_ex3 +```{solution} prob_ex3 :class: dropdown ``` @@ -288,7 +285,7 @@ plt.show() We can see that the output graph is the same as the one above. -```{solution-end} +```{solution} ``` #### Geometric distribution diff --git a/book/pv.md b/lectures/pv.md similarity index 99% rename from book/pv.md rename to lectures/pv.md index da7d925..5488d32 100644 --- a/book/pv.md +++ b/lectures/pv.md @@ -279,7 +279,7 @@ Compute the corresponding asset price sequence when $p^*_{T+1} = 0$ and $\delta ```{exercise-end} ``` -```{solution-start} pv_ex_cyc +```{solution} pv_ex_cyc :class: dropdown ``` @@ -311,7 +311,7 @@ The weighted averaging associated with the present value calculation largely eliminates the cycles. -```{solution-end} +```{solution} ``` ## Analytical expressions @@ -466,7 +466,7 @@ following settings for $d$ and $p_{T+1}^*$: ```{exercise-end} ``` -```{solution-start} pv_ex_a +```{solution} pv_ex_a :class: dropdown ``` @@ -480,5 +480,5 @@ Plugging each of the above $p_{T+1}^*, d_t$ pairs into Equation {eq}`eq:ptpveq` 4. $p_t = c \delta^{-t}$ -```{solution-end} +```{solution} ``` \ No newline at end of file diff --git a/book/scalar_dynam.md b/lectures/scalar_dynam.md similarity index 99% rename from book/scalar_dynam.md rename to lectures/scalar_dynam.md index 5926a3f..dc3dcca 100644 --- a/book/scalar_dynam.md +++ b/lectures/scalar_dynam.md @@ -564,7 +564,7 @@ Use $a=0.5$ and then $a=-0.5$ and study the trajectories. Set $b=1$ throughout. ``` -```{solution-start} sd_ex1 +```{solution} sd_ex1 :class: dropdown ``` @@ -624,5 +624,5 @@ and back again. In the current context, the series is said to exhibit **damped oscillations**. -```{solution-end} +```{solution} ``` diff --git a/book/schelling.md b/lectures/schelling.md similarity index 99% rename from book/schelling.md rename to lectures/schelling.md index 8032e10..1dde996 100644 --- a/book/schelling.md +++ b/lectures/schelling.md @@ -363,7 +363,7 @@ with small probability, is replaced by an agent of the other type.) ```{exercise-end} ``` -```{solution-start} schelling_ex1 +```{solution} schelling_ex1 :class: dropdown ``` solution here @@ -470,7 +470,7 @@ def sim_random_select(max_iter=100_000, flip_prob=0.01, test_freq=10_000): print(f"Terminating at iteration {current_iter}") ``` -```{solution-end} +```{solution} ``` +++ diff --git a/book/short_path.md b/lectures/short_path.md similarity index 99% rename from book/short_path.md rename to lectures/short_path.md index c1e236c..2bab559 100644 --- a/book/short_path.md +++ b/lectures/short_path.md @@ -285,7 +285,7 @@ print(graph_file_data) ```{exercise-end} ``` -```{solution-start} short_path_ex1 +```{solution} short_path_ex1 :class: dropdown ``` @@ -384,5 +384,5 @@ The total cost of the path should agree with $J[0]$ so let's check this. J[0] ``` -```{solution-end} +```{solution} ``` diff --git a/book/simple_linear_regression.md b/lectures/simple_linear_regression.md similarity index 100% rename from book/simple_linear_regression.md rename to lectures/simple_linear_regression.md diff --git a/book/solow.md b/lectures/solow.md similarity index 99% rename from book/solow.md rename to lectures/solow.md index ee02b8b..1ce2c73 100644 --- a/book/solow.md +++ b/lectures/solow.md @@ -437,7 +437,7 @@ Also, find the approximate value of $s$ that maximizes the $c^*(s)$ and show it ``` -```{solution-start} solow_ex1 +```{solution} solow_ex1 :class: dropdown ``` @@ -529,7 +529,7 @@ print(f"s_star = {s_star}") Incidentally, the rate of savings which maximizes steady state level of per capita consumption is called the [Golden Rule savings rate](https://en.wikipedia.org/wiki/Golden_Rule_savings_rate). -```{solution-end} +```{solution} ``` ```{exercise-start} @@ -568,7 +568,7 @@ Generate and plot the time series $k_t$. ```{exercise-end} ``` -```{solution-start} solow_ex2 +```{solution} solow_ex2 :class: dropdown ``` @@ -623,5 +623,5 @@ ts_plot(x0, 50) -```{solution-end} +```{solution} ``` diff --git a/book/status.md b/lectures/status.md similarity index 100% rename from book/status.md rename to lectures/status.md diff --git a/book/supply_demand_heterogeneity.md b/lectures/supply_demand_heterogeneity.md similarity index 100% rename from book/supply_demand_heterogeneity.md rename to lectures/supply_demand_heterogeneity.md diff --git a/book/supply_demand_multiple_goods.md b/lectures/supply_demand_multiple_goods.md similarity index 99% rename from book/supply_demand_multiple_goods.md rename to lectures/supply_demand_multiple_goods.md index 5a010ce..a1d4b41 100644 --- a/book/supply_demand_multiple_goods.md +++ b/lectures/supply_demand_multiple_goods.md @@ -485,7 +485,7 @@ Hints. For each case choose some parameter $e, b, \text{ or } \lambda$ different +++ -```{solution-start} sdm_ex3 +```{solution} sdm_ex3 :class: dropdown ``` @@ -531,7 +531,7 @@ print('Competitive equilibrium price vector:', p) print('Competitive equilibrium allocation:', c) ``` -```{solution-end} +```{solution} ``` +++ diff --git a/book/tax_smooth.md b/lectures/tax_smooth.md similarity index 100% rename from book/tax_smooth.md rename to lectures/tax_smooth.md diff --git a/book/time_series_with_matrices.md b/lectures/time_series_with_matrices.md similarity index 100% rename from book/time_series_with_matrices.md rename to lectures/time_series_with_matrices.md diff --git a/book/troubleshooting.md b/lectures/troubleshooting.md similarity index 100% rename from book/troubleshooting.md rename to lectures/troubleshooting.md diff --git a/book/unpleasant.md b/lectures/unpleasant.md similarity index 100% rename from book/unpleasant.md rename to lectures/unpleasant.md diff --git a/book/zreferences.md b/lectures/zreferences.md similarity index 100% rename from book/zreferences.md rename to lectures/zreferences.md diff --git a/update_lectures.py b/update_lectures.py index 58803a9..9be4597 100644 --- a/update_lectures.py +++ b/update_lectures.py @@ -66,6 +66,15 @@ def update_pip_line(line): if ("!pip" in line_) and ("install" in line_): line_ = line_.replace("!", "").replace("pip", "%pip") line_ = line_.replace("--upgrade", "") + + # Hack for handling solution and exercise note execution + # ```{solution-end} + if "```{solution-end}" or "```{solution-start}" in line_: + line_ = line_.replace("```{solution-end}", "```{solution}") + line_ = line_.replace("```{solution-start}", "```{solution}") + elif "```{exercise-end}" or "```{exercise-start}" in line_: + line_ = line_.replace("```{exercise-end}", "```{exercise}") + line_ = line_.replace("```{exercise-start}", "```{exercise}") return line_ @@ -75,7 +84,7 @@ def update_lectures(): in_dir_1 = os.path.abspath(os.path.join(ROOT_DIR, 'lecture-python-intro-wasm')) in_dir_2 = os.path.abspath(os.path.join(in_dir_1, 'lectures')) - out_dir = os.path.abspath(os.path.join(ROOT_DIR, 'book')) + out_dir = os.path.abspath(os.path.join(ROOT_DIR, 'lectures')) shutil.copytree(in_dir_2, out_dir, dirs_exist_ok=True) cwd = os.getcwd() @@ -99,9 +108,9 @@ def update_lectures(): f.writelines(out_lines) # Update _config.yml file - source_config = os.path.abspath(os.path.join(ROOT_DIR, '_config_copy.yml')) - destination_config = os.path.abspath(os.path.join(out_dir, '_config.yml')) - shutil.copyfile(source_config, destination_config) + # source_config = os.path.abspath(os.path.join(ROOT_DIR, '_config_copy.yml')) + # destination_config = os.path.abspath(os.path.join(out_dir, '_config.yml')) + # shutil.copyfile(source_config, destination_config) # Remove downloaded folder shutil.rmtree('lecture-python-intro-wasm')