Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try out sphinx-exercise for exercise formatting #5

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ bibtex_bibfiles:
sphinx:
config:
bibtex_reference_style: author_year # or label, super, \supercite
extra_extensions:
- sphinx_exercise
- sphinx_togglebutton
3 changes: 3 additions & 0 deletions conda/environment-unpinned.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies:
- hvplot
- matplotlib-base
- netcdf4
- pip
- pint-xarray
- pydap
- python-graphviz
Expand All @@ -29,3 +30,5 @@ dependencies:
- scipy
- xarray
- zarr
- pip:
- sphinx-exercise
23 changes: 19 additions & 4 deletions fundamentals/02.3_aligning_data_objects.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,15 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"tags": []
},
"source": [
"**Exercise** Consider the following two arrays. Write down the `x` and `y` coordinate locations for `da1 - da2`"
"```{exercise-start}\n",
":label: exercise-alignment\n",
"\n",
"Consider the following two arrays. Write down the `x` and `y` coordinate locations for `da1 - da2`\n",
"```"
]
},
{
Expand All @@ -388,6 +394,7 @@
"metadata": {},
"outputs": [],
"source": [
"# This code cell is executed by jupyterbook\n",
"da1 = xr.DataArray(\n",
" np.arange(12).reshape(3, 4),\n",
" dims=(\"x\", \"y\"),\n",
Expand All @@ -408,7 +415,15 @@
]
},
"source": [
"**Answer** `x = [\"b\"], y=[0, 1, 2, 3]` . `da2` has been broadcasted to 2D (so dimension \"y\" has been inserted) and the two arrays are aligned using `join=\"inner\"` prior to subtraction."
"```{exercise-end}\n",
"```\n",
"\n",
"```{solution} exercise-alignment\n",
":label: solution-alignment\n",
":class: dropdown\n",
"\n",
"`x = [\"b\"], y=[0, 1, 2, 3]` . `da2` has been broadcasted to 2D (so dimension \"y\" has been inserted) and the two arrays are aligned using `join=\"inner\"` prior to subtraction.\n",
"```"
]
},
{
Expand Down Expand Up @@ -510,7 +525,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.10.5"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
Expand Down