From 16e34b0f56b9d80962f8ad0e11275defd0d537db Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 24 Jul 2023 23:18:38 +0100 Subject: [PATCH 1/3] Use examples gallery for notebooks --- Documentation/_static/override-nbsphinx-gallery.css | 3 +++ Documentation/conf.py | 4 ++++ Documentation/overview/index.rst | 5 ++++- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 Documentation/_static/override-nbsphinx-gallery.css diff --git a/Documentation/_static/override-nbsphinx-gallery.css b/Documentation/_static/override-nbsphinx-gallery.css new file mode 100644 index 000000000..65ee21fe6 --- /dev/null +++ b/Documentation/_static/override-nbsphinx-gallery.css @@ -0,0 +1,3 @@ +.nbsphinx-gallery { + grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); +} diff --git a/Documentation/conf.py b/Documentation/conf.py index 27de694f3..7be168aa2 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py @@ -62,6 +62,10 @@ # HTML writer configuration html_theme = "pydata_sphinx_theme" +html_static_path = ["_static"] +html_css_files = [ + 'override-nbsphinx-gallery.css', +] html_theme_options = { "use_edit_page_button": True, diff --git a/Documentation/overview/index.rst b/Documentation/overview/index.rst index 84250099c..9671f673f 100644 --- a/Documentation/overview/index.rst +++ b/Documentation/overview/index.rst @@ -8,7 +8,10 @@ Overview introduction ARKitecture -.. toctree:: +.. nbgallery is a wrapper around the toctree directive, see + https://nbsphinx.readthedocs.io/en/latest/a-normal-rst-file.html#thumbnail-galleries + +.. nbgallery:: :caption: Examples :maxdepth: 1 From 96105514347cfdfc58b13dc1de7db0d55b0dd5c8 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 24 Jul 2023 23:19:13 +0100 Subject: [PATCH 2/3] Add cell metadata for notebook thumbnail image --- examples/Gentle-Intro/Gentle-Intro-To-HARK.ipynb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/Gentle-Intro/Gentle-Intro-To-HARK.ipynb b/examples/Gentle-Intro/Gentle-Intro-To-HARK.ipynb index 76f84c9ce..a22a4f123 100644 --- a/examples/Gentle-Intro/Gentle-Intro-To-HARK.ipynb +++ b/examples/Gentle-Intro/Gentle-Intro-To-HARK.ipynb @@ -383,7 +383,8 @@ "iopub.status.busy": "2023-02-07T00:50:32.939429Z", "iopub.status.idle": "2023-02-07T00:50:33.094965Z", "shell.execute_reply": "2023-02-07T00:50:33.094965Z" - } + }, + "nbsphinx-thumbnail": {} }, "outputs": [ { From df8d87746570190891943229677241316a03bbb2 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 24 Jul 2023 23:19:25 +0100 Subject: [PATCH 3/3] Rename notebooks for shorter titles --- examples/ConsIndShockModel/IndShockConsumerType.ipynb | 5 +++-- examples/ConsIndShockModel/KinkedRconsumerType.ipynb | 4 +++- examples/ConsIndShockModel/PerfForesightConsumerType.ipynb | 4 +++- .../HowWeSolveIndShockConsumerType.ipynb | 3 ++- examples/LifecycleModel/LifecycleModel.ipynb | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/examples/ConsIndShockModel/IndShockConsumerType.ipynb b/examples/ConsIndShockModel/IndShockConsumerType.ipynb index e80f4dbaa..c74d713f7 100644 --- a/examples/ConsIndShockModel/IndShockConsumerType.ipynb +++ b/examples/ConsIndShockModel/IndShockConsumerType.ipynb @@ -4,8 +4,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# IndShockConsumerType Documentation\n", - "## Consumption-Saving model with Idiosyncratic Income Shocks" + "# Consumption-Saving model with Idiosyncratic Income Shocks\n", + "\n", + "**The `IndShockConsumerType` class**" ] }, { diff --git a/examples/ConsIndShockModel/KinkedRconsumerType.ipynb b/examples/ConsIndShockModel/KinkedRconsumerType.ipynb index dbfb385bc..fc1e0cce6 100644 --- a/examples/ConsIndShockModel/KinkedRconsumerType.ipynb +++ b/examples/ConsIndShockModel/KinkedRconsumerType.ipynb @@ -6,7 +6,9 @@ "lines_to_next_cell": 2 }, "source": [ - "# KinkedRconsumerType: Consumption-saving model with idiosyncratic income shocks and different interest rates on borrowing and saving" + "# Consumption-Saving model with Idiosyncratic Income Shocks and Different Interest Rates on Borrowing and Saving\n", + "\n", + "**The `KinkedRconsumerType` class**" ] }, { diff --git a/examples/ConsIndShockModel/PerfForesightConsumerType.ipynb b/examples/ConsIndShockModel/PerfForesightConsumerType.ipynb index e44551f17..3c68f358c 100644 --- a/examples/ConsIndShockModel/PerfForesightConsumerType.ipynb +++ b/examples/ConsIndShockModel/PerfForesightConsumerType.ipynb @@ -6,7 +6,9 @@ "lines_to_next_cell": 2 }, "source": [ - "# PerfForesightConsumerType: Perfect foresight consumption-saving" + "# Perfect foresight consumption-saving\n", + "\n", + "**The `PerfForesightConsumerType` class**" ] }, { diff --git a/examples/HowWeSolveIndShockConsumerType/HowWeSolveIndShockConsumerType.ipynb b/examples/HowWeSolveIndShockConsumerType/HowWeSolveIndShockConsumerType.ipynb index d7ff1489b..d23cf7a61 100644 --- a/examples/HowWeSolveIndShockConsumerType/HowWeSolveIndShockConsumerType.ipynb +++ b/examples/HowWeSolveIndShockConsumerType/HowWeSolveIndShockConsumerType.ipynb @@ -4,7 +4,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# How we solve a model defined by the `IndShockConsumerType` class\n", + "# How we solve a model defined by `IndShockConsumerType`\n", + "\n", "The IndShockConsumerType reprents the work-horse consumption savings model with temporary and permanent shocks to income, finite or infinite horizons, CRRA utility and more. In this DemARK we take you through the steps involved in solving one period of such a model. The inheritance chains can be a little long, so figuring out where all the parameters and methods come from can be a bit confusing. Hence this map! The intention is to make it easier to know how to inheret from IndShockConsumerType in the sense that you know where to look for specific solver logic, but also so you know can figure out which methods to overwrite or supplement in your own `AgentType` and solver!\n", "## The `solveConsIndShock` function\n", "In HARK, a period's problem is always solved by the callable (function or callable object instance) stored in the field `solve_one_period`. In the case of `IndShockConsumerType`, this function is called `solveConsIndShock`. The function accepts a number of arguments, that it uses to construct an instance of either a `ConsIndShockSolverBasic` or a `ConsIndShockSolver`. These solvers both have the methods `prepare_to_solve` and `solve`, that we will have a closer look at in this notebook. This means, that the logic of `solveConsIndShock` is basically:\n", diff --git a/examples/LifecycleModel/LifecycleModel.ipynb b/examples/LifecycleModel/LifecycleModel.ipynb index 91671395e..06be09523 100644 --- a/examples/LifecycleModel/LifecycleModel.ipynb +++ b/examples/LifecycleModel/LifecycleModel.ipynb @@ -5,7 +5,7 @@ "metadata": {}, "source": [ "\n", - "# A Lifecycle Model: The Distribution of Assets By Age\n", + "# A Life Cycle Model: The Distribution of Assets By Age\n", "\n", "National registry data on income and wealth from Scandinavian countries has recently become available (with a lot of security) to some (lucky!) researchers. These data offer a uniquely powerful tool for testing (and improving) our models of consumption and saving behavior over the life cycle.\n", "\n",