Skip to content

Commit

Permalink
Clean up notebooks (#208)
Browse files Browse the repository at this point in the history
* Remove jupyter notebook extensions, use jupyterlab

* Remove .py jupytext sync files

* clean up notebooks

* run notebooks

* fix diamond

* ignore Harmenberg-Aggregation notebook
  • Loading branch information
MridulS committed Nov 29, 2023
1 parent 45a4cde commit 6d0aa34
Show file tree
Hide file tree
Showing 46 changed files with 1,039 additions and 16,153 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
- name: Test with nbval
shell: bash -l {0}
run: |
python -m pytest --nbval-lax --nbval-cell-timeout=12000 --ignore=notebooks/Chinese-Growth.ipynb notebooks/
python -m pytest --nbval-lax --nbval-cell-timeout=12000 --ignore=notebooks/Chinese-Growth.ipynb --ignore=notebooks/Harmenberg-Aggregation.ipynb notebooks/
1 change: 0 additions & 1 deletion binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ dependencies:
- nbval
- pip
- pip:
- cite2c
- git+https://github.com/econ-ark/hark@master
14 changes: 0 additions & 14 deletions binder/postBuild

This file was deleted.

16 changes: 0 additions & 16 deletions binder/postBuild.bat

This file was deleted.

144 changes: 28 additions & 116 deletions notebooks/Alternative-Combos-Of-Parameter-Values.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
"\n",
"[![badge](https://img.shields.io/badge/Launch%20using%20-Econ--ARK-blue)](https://econ-ark.org/materials/alternative-combos-of-parameter-values#launch)\n",
"\n",
"Please write the names and email addresses of everyone who worked on this notebook on the line below.\n",
"\n",
"YOUR NAMES HERE\n",
"\n",
"## Introduction\n",
"\n",
"The notebook \"Micro-and-Macro-Implications-of-Very-Impatient-HHs\" is an exercise that demonstrates the consequences of changing a key parameter of the [cstwMPC](http://www.econ2.jhu.edu/people/ccarroll/papers/cstwMPC) model, the time preference factor $\\beta$.\n",
Expand Down Expand Up @@ -46,21 +42,10 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"code_folding": [],
"execution": {
"iopub.execute_input": "2023-01-20T20:49:17.366724Z",
"iopub.status.busy": "2023-01-20T20:49:17.366724Z",
"iopub.status.idle": "2023-01-20T20:49:18.978028Z",
"shell.execute_reply": "2023-01-20T20:49:18.978028Z"
},
"lines_to_next_cell": 2
},
"metadata": {},
"outputs": [],
"source": [
"# This cell merely imports and sets up some basic functions and packages\n",
"\n",
"%matplotlib inline\n",
"from HARK.utilities import get_lorenz_shares, get_percentiles\n",
"from tqdm import tqdm\n",
"import numpy as np"
Expand All @@ -69,18 +54,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"code_folding": [
0,
4
],
"execution": {
"iopub.execute_input": "2023-01-20T20:49:18.982029Z",
"iopub.status.busy": "2023-01-20T20:49:18.981028Z",
"iopub.status.idle": "2023-01-20T20:49:19.042547Z",
"shell.execute_reply": "2023-01-20T20:49:19.041546Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"# Import IndShockConsumerType\n",
Expand Down Expand Up @@ -133,14 +107,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"execution": {
"iopub.execute_input": "2023-01-20T20:49:19.045547Z",
"iopub.status.busy": "2023-01-20T20:49:19.044548Z",
"iopub.status.idle": "2023-01-20T20:49:19.057547Z",
"shell.execute_reply": "2023-01-20T20:49:19.057547Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"# Construct a list of solved consumers' problems, IndShockConsumerType is just a place holder\n",
Expand All @@ -157,50 +124,19 @@
"\n",
"But the fact that everyone has the same target ${m}$ does not mean that the _distribution_ of ${m}$ will be the same for all of these consumer types.\n",
"\n",
"In the code block below, fill in the contents of the loop to solve and simulate each agent type for many periods. To do this, you should invoke the methods $\\texttt{solve}$, $\\texttt{initialize_sim}$, and $\\texttt{simulate}$ in that order. Simulating for 1200 quarters (300 years) will approximate the long run distribution of wealth in the population."
"In the code block below, fill in the contents of the loop to solve and simulate each agent type for many periods. To do this, you should invoke the methods $\\texttt{solve}$, $\\texttt{initialize\\_sim}$, and $\\texttt{simulate}$ in that order. Simulating for 1200 quarters (300 years) will approximate the long run distribution of wealth in the population."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"execution": {
"iopub.execute_input": "2023-01-20T20:49:19.060547Z",
"iopub.status.busy": "2023-01-20T20:49:19.060547Z",
"iopub.status.idle": "2023-01-20T20:49:22.343738Z",
"shell.execute_reply": "2023-01-20T20:49:22.343738Z"
}
},
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 0%| | 0/1 [00:00<?, ?it/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
"100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:03<00:00, 3.26s/it]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
"100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:03<00:00, 3.27s/it]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n"
"100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:03<00:00, 3.03s/it]\n"
]
}
],
Expand All @@ -221,14 +157,7 @@
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"execution": {
"iopub.execute_input": "2023-01-20T20:49:22.346737Z",
"iopub.status.busy": "2023-01-20T20:49:22.345738Z",
"iopub.status.idle": "2023-01-20T20:49:22.359737Z",
"shell.execute_reply": "2023-01-20T20:49:22.359737Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"# To help you out, we have given you the command needed to construct a list of the levels of assets for all consumers\n",
Expand Down Expand Up @@ -258,15 +187,7 @@
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"execution": {
"iopub.execute_input": "2023-01-20T20:49:22.362741Z",
"iopub.status.busy": "2023-01-20T20:49:22.362741Z",
"iopub.status.idle": "2023-01-20T20:49:22.375738Z",
"shell.execute_reply": "2023-01-20T20:49:22.375738Z"
},
"lines_to_next_cell": 2
},
"metadata": {},
"outputs": [],
"source": [
"# Finish filling in this function to calculate the Euclidean distance between the simulated and actual Lorenz curves.\n",
Expand Down Expand Up @@ -306,9 +227,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"lines_to_next_cell": 2
},
"metadata": {},
"source": [
"## ...and the Marginal Propensity to Consume\n",
"\n",
Expand All @@ -324,38 +243,31 @@
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"execution": {
"iopub.execute_input": "2023-01-20T20:49:22.378741Z",
"iopub.status.busy": "2023-01-20T20:49:22.377739Z",
"iopub.status.idle": "2023-01-20T20:49:22.391737Z",
"shell.execute_reply": "2023-01-20T20:49:22.391737Z"
}
},
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The 5.0th percentile of the MPC is 0.3830226479018113\n",
"The 5.0th percentile of the MPC is 0.3830226479018095\n",
"The 10.0th percentile of the MPC is 0.4190098031734306\n",
"The 15.0th percentile of the MPC is 0.4598470116058213\n",
"The 20.0th percentile of the MPC is 0.4598470116058213\n",
"The 25.0th percentile of the MPC is 0.4598470116058213\n",
"The 30.0th percentile of the MPC is 0.4979166414954129\n",
"The 35.0th percentile of the MPC is 0.4979166414954129\n",
"The 40.0th percentile of the MPC is 0.4979166414954129\n",
"The 44.99999999999999th percentile of the MPC is 0.5372418610399285\n",
"The 49.99999999999999th percentile of the MPC is 0.5372418610399285\n",
"The 54.99999999999999th percentile of the MPC is 0.5372418610399285\n",
"The 60.0th percentile of the MPC is 0.5821887061769021\n",
"The 65.0th percentile of the MPC is 0.5821887061769021\n",
"The 70.0th percentile of the MPC is 0.6345373126858305\n",
"The 75.0th percentile of the MPC is 0.6345373126858305\n",
"The 80.0th percentile of the MPC is 0.7267307307276039\n",
"The 15.0th percentile of the MPC is 0.45984701160581964\n",
"The 20.0th percentile of the MPC is 0.45984701160581964\n",
"The 25.0th percentile of the MPC is 0.45984701160581964\n",
"The 30.0th percentile of the MPC is 0.4979166414954148\n",
"The 35.0th percentile of the MPC is 0.4979166414954148\n",
"The 40.0th percentile of the MPC is 0.4979166414954148\n",
"The 44.99999999999999th percentile of the MPC is 0.5372418610399308\n",
"The 49.99999999999999th percentile of the MPC is 0.5372418610399308\n",
"The 54.99999999999999th percentile of the MPC is 0.5372418610399308\n",
"The 60.0th percentile of the MPC is 0.5821887061768969\n",
"The 65.0th percentile of the MPC is 0.5821887061768969\n",
"The 70.0th percentile of the MPC is 0.634537312685834\n",
"The 75.0th percentile of the MPC is 0.634537312685834\n",
"The 80.0th percentile of the MPC is 0.7267307307276032\n",
"The 85.0th percentile of the MPC is 0.7799255201452847\n",
"The 90.0th percentile of the MPC is 0.8208530902866041\n",
"The 95.0th percentile of the MPC is 0.8966083611183644\n"
"The 90.0th percentile of the MPC is 0.8208530902866055\n",
"The 95.0th percentile of the MPC is 0.8966083611183647\n"
]
}
],
Expand Down Expand Up @@ -411,7 +323,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
"version": "3.10.13"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
Expand Down

0 comments on commit 6d0aa34

Please sign in to comment.