Skip to content

Commit d4d0e34

Browse files
authored
Rework example gallery (#58)
* Add test reference to readme * Add custom thumbnail support * Rework example notebooks * Add name arg to gen_random
1 parent 40fffb4 commit d4d0e34

15 files changed

+348
-481
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ For any operating system, install the following:
9797

9898
[work in progress]
9999

100+
## Testing
101+
102+
To find out how to run the tests of the pytopotoolbox, refer to the dedicated [readme](./test/README.md) in the /tests directory.
103+
100104
## Contributing
101105

102106
If you would like to contribute to pytopotoolbox, check out the [Contribution Guidelines](./CONTRIBUTING.md).
17.6 KB
Loading

docs/conf.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
# Configuration file for the Sphinx documentation builder.
2-
#
3-
# For the full list of built-in configuration values, see the documentation:
4-
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5-
6-
# -- Project information -----------------------------------------------------
7-
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8-
91
import os
102
import sys
113

@@ -21,7 +13,6 @@
2113
'sphinx.ext.viewcode',
2214
'sphinx.ext.todo',
2315
'nbsphinx',
24-
'myst_parser',
2516
]
2617

2718
project = 'TopoToolbox'
@@ -30,14 +21,11 @@
3021
release = '3.0.1'
3122

3223
# -- General configuration ---------------------------------------------------
33-
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
3424

3525
templates_path = ['_templates']
3626
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'README.md']
3727

38-
3928
# -- Options for HTML output -------------------------------------------------
40-
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
4129

4230
html_theme = 'sphinx_book_theme'
4331
html_static_path = ['_static']
@@ -57,9 +45,17 @@
5745
'members': True,
5846
'undoc-members': True,
5947
'private-members': False,
60-
'special-members': '__init__',
6148
'inherited-members': True,
6249
'show-inheritance': True,
6350
}
6451

6552
autosummary_generate = True # Enable autosummary to generate stub files
53+
54+
# -- Options for nbgallery ---------------------------------------------------
55+
56+
nbsphinx_thumbnails = {
57+
'_temp/excesstopography': '_static/thumbnails/placeholder.png',
58+
'_temp/magicfunctions': '_static/thumbnails/placeholder.png',
59+
'_temp/plotting': '_static/thumbnails/placeholder.png',
60+
'_temp/downloading': '_static/thumbnails/placeholder.png',
61+
}

docs/examples.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ Examples
22
========
33

44
.. nbgallery::
5-
/_temp/excesstopography.ipynb
6-
/_temp/plotting.ipynb
7-
/_temp/test_genGrid
8-
/_temp/test_GridObject
9-
/_temp/test_load_dem
10-
/_temp/example_magic_funcs
5+
/_temp/excesstopography
6+
/_temp/magicfunctions
7+
/_temp/plotting
8+
/_temp/downloading

docs/requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
Sphinx==7.3.7
22
sphinx-book-theme==1.1.2
33
nbsphinx==0.9.4
4-
notebook==7.0.5
5-
myst_parser
4+
notebook==7.0.5

examples/downloading.ipynb

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"Loading an example GridObject\n",
8+
"=============================\n",
9+
"\n",
10+
"The TopoToolbox provides a few example .tif files. These Files will get saved in a local cache. To delete these Files, run `topotoolbox.clear_cache()`."
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": 2,
16+
"metadata": {},
17+
"outputs": [
18+
{
19+
"name": "stdout",
20+
"output_type": "stream",
21+
"text": [
22+
"['kedarnath', 'kunashiri', 'perfectworld', 'taalvolcano', 'taiwan', 'tibet']\n",
23+
"\n",
24+
"name: taiwan\n",
25+
"path: /home/theo/.cache/topotoolbox/taiwan.tif\n",
26+
"rows: 4181\n",
27+
"cols: 2253\n",
28+
"cellsize: 90.0\n",
29+
"bounds: BoundingBox(left=197038.4533204764, bottom=2422805.9007333447, right=399808.4533204764, top=2799095.9007333447)\n",
30+
"transform: | 90.00, 0.00, 197038.45|\n",
31+
"| 0.00,-90.00, 2799095.90|\n",
32+
"| 0.00, 0.00, 1.00|\n",
33+
"crs: EPSG:32651\n",
34+
"\n",
35+
"['kunashiri.tif', 'perfectworld.tif', 'tibet.tif', 'taiwan.tif', 'kedarnath.tif']\n"
36+
]
37+
}
38+
],
39+
"source": [
40+
"import topotoolbox as topo\n",
41+
"\n",
42+
"# Print all available example files\n",
43+
"print(f\"{topo.get_dem_names()}\\n\")\n",
44+
"\n",
45+
"# Download an example file\n",
46+
"dem = topo.load_dem(\"taiwan\")\n",
47+
"dem.info()\n",
48+
"\n",
49+
"# Print all files currently saved in your cache\n",
50+
"print(f\"\\n{topo.get_cache_contents()}\")"
51+
]
52+
}
53+
],
54+
"metadata": {
55+
"kernelspec": {
56+
"display_name": "Python 3 (ipykernel)",
57+
"language": "python",
58+
"name": "python3"
59+
},
60+
"language_info": {
61+
"codemirror_mode": {
62+
"name": "ipython",
63+
"version": 3
64+
},
65+
"file_extension": ".py",
66+
"mimetype": "text/x-python",
67+
"name": "python",
68+
"nbconvert_exporter": "python",
69+
"pygments_lexer": "ipython3",
70+
"version": "3.10.12"
71+
}
72+
},
73+
"nbformat": 4,
74+
"nbformat_minor": 2
75+
}

examples/example_magic_funcs.ipynb

Lines changed: 0 additions & 157 deletions
This file was deleted.

examples/excesstopography.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"cell_type": "markdown",
5252
"metadata": {},
5353
"source": [
54-
"If some sections of the GridObject should be differently than others, use another GridObject or np.ndarray to add custom value for the threshold slopes. Make sure that the shape of your threshold matches the one of your GridObject."
54+
"If some sections of the GridObject should be evaluated differently than others, use another GridObject or np.ndarray to add custom value for the threshold slopes. Make sure that the shape of your threshold matches the one of your GridObject."
5555
]
5656
},
5757
{

0 commit comments

Comments
 (0)