Skip to content

Commit 7fb2919

Browse files
committed
Add: example documentation with gallery
1 parent 74e20ee commit 7fb2919

20 files changed

+502
-85
lines changed

.gitignore

Lines changed: 1 addition & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
# Byte-compiled / optimized / DLL files
22
__pycache__/
3-
*.py[cod]
4-
*$py.class
3+
.DS_Store
54

6-
# C extensions
7-
*.so
85

96
# Distribution / packaging
107
.Python
@@ -27,15 +24,6 @@ share/python-wheels/
2724
*.egg
2825
MANIFEST
2926

30-
# PyInstaller
31-
# Usually these files are written by a python script from a template
32-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33-
*.manifest
34-
*.spec
35-
36-
# Installer logs
37-
pip-log.txt
38-
pip-delete-this-directory.txt
3927

4028
# Unit test / coverage reports
4129
htmlcov/
@@ -51,79 +39,9 @@ coverage.xml
5139
.hypothesis/
5240
.pytest_cache/
5341

54-
# Translations
55-
*.mo
56-
*.pot
57-
58-
# Django stuff:
59-
*.log
60-
local_settings.py
61-
db.sqlite3
62-
db.sqlite3-journal
63-
64-
# Flask stuff:
65-
instance/
66-
.webassets-cache
67-
68-
# Scrapy stuff:
69-
.scrapy
7042

7143
# Sphinx documentation
7244
docs/_build/
7345

74-
# PyBuilder
75-
target/
76-
7746
# Jupyter Notebook
7847
.ipynb_checkpoints
79-
80-
# IPython
81-
profile_default/
82-
ipython_config.py
83-
84-
# pyenv
85-
.python-version
86-
87-
# pipenv
88-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91-
# install all needed dependencies.
92-
#Pipfile.lock
93-
94-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95-
__pypackages__/
96-
97-
# Celery stuff
98-
celerybeat-schedule
99-
celerybeat.pid
100-
101-
# SageMath parsed files
102-
*.sage.py
103-
104-
# Environments
105-
.env
106-
.venv
107-
env/
108-
venv/
109-
ENV/
110-
env.bak/
111-
venv.bak/
112-
113-
# Spyder project settings
114-
.spyderproject
115-
.spyproject
116-
117-
# Rope project settings
118-
.ropeproject
119-
120-
# mkdocs documentation
121-
/site
122-
123-
# mypy
124-
.mypy_cache/
125-
.dmypy.json
126-
dmypy.json
127-
128-
# Pyre type checker
129-
.pyre/

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
# examplePy
2-
An example python package to be used in our tutorials
1+
# examplePy
2+
3+
An example Python package to be used in our pyOpenSci tutorials.
4+
5+
## Learn more about pyOpenSci
6+
7+
[Learn more about us. ](https://www.pyopensci.org)
8+
9+
10+

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2.04 KB
Binary file not shown.
1.09 KB
Binary file not shown.
Loading

docs/built_examples/index.rst

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
:orphan:
2+
3+
Example Sphinx Gallery
4+
=======================
5+
6+
Below is a gallery of examples
7+
8+
9+
.. raw:: html
10+
11+
<div class="sphx-glr-thumbnails">
12+
13+
14+
.. raw:: html
15+
16+
<div class="sphx-glr-thumbcontainer" tooltip="This example demonstrates a Seaborn plot. Figures produced Matplotlib **and** by any package th...">
17+
18+
.. only:: html
19+
20+
.. image:: /built_examples/images/thumb/sphx_glr_sample_thumb.png
21+
:alt: Seaborn example
22+
23+
:ref:`sphx_glr_built_examples_sample.py`
24+
25+
.. raw:: html
26+
27+
<div class="sphx-glr-thumbnail-title">Seaborn example</div>
28+
</div>
29+
30+
31+
.. raw:: html
32+
33+
</div>
34+
35+
36+
.. toctree::
37+
:hidden:
38+
39+
/built_examples/sample
40+
41+
42+
.. only:: html
43+
44+
.. container:: sphx-glr-footer sphx-glr-footer-gallery
45+
46+
.. container:: sphx-glr-download sphx-glr-download-python
47+
48+
:download:`Download all examples in Python source code: built_examples_python.zip </built_examples/built_examples_python.zip>`
49+
50+
.. container:: sphx-glr-download sphx-glr-download-jupyter
51+
52+
:download:`Download all examples in Jupyter notebooks: built_examples_jupyter.zip </built_examples/built_examples_jupyter.zip>`
53+
54+
55+
.. only:: html
56+
57+
.. rst-class:: sphx-glr-signature
58+
59+
`Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_

docs/built_examples/sample.ipynb

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {
7+
"collapsed": false
8+
},
9+
"outputs": [],
10+
"source": [
11+
"%matplotlib inline"
12+
]
13+
},
14+
{
15+
"cell_type": "markdown",
16+
"metadata": {},
17+
"source": [
18+
"\n# Seaborn example\n\nThis example demonstrates a Seaborn plot. Figures produced Matplotlib **and**\nby any package that is based on Matplotlib (e.g., Seaborn), will be\ncaptured by default. See `image_scrapers` for details.\n\nThis is taken from the sphinx gallery documentation :)\n"
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": null,
24+
"metadata": {
25+
"collapsed": false
26+
},
27+
"outputs": [],
28+
"source": [
29+
"# Author: Michael Waskom & Lucy Liu\n# License: BSD 3 clause\n\nfrom __future__ import division, absolute_import, print_function\n\n\nimport numpy as np\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\n# Enforce the use of default set style\n\n# Create a noisy periodic dataset\ny_array = np.array([])\nx_array = np.array([])\nrs = np.random.RandomState(8)\nfor _ in range(15):\n x = np.linspace(0, 30 / 2, 30)\n y = np.sin(x) + rs.normal(0, 1.5) + rs.normal(0, .3, 30)\n y_array = np.append(y_array, y)\n x_array = np.append(x_array, x)\n\n# Plot the average over replicates with confidence interval\nsns.lineplot(y=y_array, x=x_array)\n# to avoid text output\nplt.show()"
30+
]
31+
}
32+
],
33+
"metadata": {
34+
"kernelspec": {
35+
"display_name": "Python 3",
36+
"language": "python",
37+
"name": "python3"
38+
},
39+
"language_info": {
40+
"codemirror_mode": {
41+
"name": "ipython",
42+
"version": 3
43+
},
44+
"file_extension": ".py",
45+
"mimetype": "text/x-python",
46+
"name": "python",
47+
"nbconvert_exporter": "python",
48+
"pygments_lexer": "ipython3",
49+
"version": "3.9.13"
50+
}
51+
},
52+
"nbformat": 4,
53+
"nbformat_minor": 0
54+
}

docs/built_examples/sample.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# -*- coding: utf-8 -*-
2+
r"""
3+
Seaborn example
4+
===============
5+
6+
This example demonstrates a Seaborn plot. Figures produced Matplotlib **and**
7+
by any package that is based on Matplotlib (e.g., Seaborn), will be
8+
captured by default. See :ref:`image_scrapers` for details.
9+
10+
This is taken from the sphinx gallery documentation :)
11+
"""
12+
# Author: Michael Waskom & Lucy Liu
13+
# License: BSD 3 clause
14+
15+
from __future__ import division, absolute_import, print_function
16+
17+
18+
import numpy as np
19+
import seaborn as sns
20+
import matplotlib.pyplot as plt
21+
22+
# Enforce the use of default set style
23+
24+
# Create a noisy periodic dataset
25+
y_array = np.array([])
26+
x_array = np.array([])
27+
rs = np.random.RandomState(8)
28+
for _ in range(15):
29+
x = np.linspace(0, 30 / 2, 30)
30+
y = np.sin(x) + rs.normal(0, 1.5) + rs.normal(0, .3, 30)
31+
y_array = np.append(y_array, y)
32+
x_array = np.append(x_array, x)
33+
34+
# Plot the average over replicates with confidence interval
35+
sns.lineplot(y=y_array, x=x_array)
36+
# to avoid text output
37+
plt.show()

docs/built_examples/sample.rst

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
2+
.. DO NOT EDIT.
3+
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
4+
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
5+
.. "built_examples/sample.py"
6+
.. LINE NUMBERS ARE GIVEN BELOW.
7+
8+
.. only:: html
9+
10+
.. note::
11+
:class: sphx-glr-download-link-note
12+
13+
Click :ref:`here <sphx_glr_download_built_examples_sample.py>`
14+
to download the full example code
15+
16+
.. rst-class:: sphx-glr-example-title
17+
18+
.. _sphx_glr_built_examples_sample.py:
19+
20+
21+
Seaborn example
22+
===============
23+
24+
This example demonstrates a Seaborn plot. Figures produced Matplotlib **and**
25+
by any package that is based on Matplotlib (e.g., Seaborn), will be
26+
captured by default. See :ref:`image_scrapers` for details.
27+
28+
This is taken from the sphinx gallery documentation :)
29+
30+
.. GENERATED FROM PYTHON SOURCE LINES 12-38
31+
32+
.. code-block:: default
33+
34+
# Author: Michael Waskom & Lucy Liu
35+
# License: BSD 3 clause
36+
37+
from __future__ import division, absolute_import, print_function
38+
39+
40+
import numpy as np
41+
import seaborn as sns
42+
import matplotlib.pyplot as plt
43+
44+
# Enforce the use of default set style
45+
46+
# Create a noisy periodic dataset
47+
y_array = np.array([])
48+
x_array = np.array([])
49+
rs = np.random.RandomState(8)
50+
for _ in range(15):
51+
x = np.linspace(0, 30 / 2, 30)
52+
y = np.sin(x) + rs.normal(0, 1.5) + rs.normal(0, .3, 30)
53+
y_array = np.append(y_array, y)
54+
x_array = np.append(x_array, x)
55+
56+
# Plot the average over replicates with confidence interval
57+
sns.lineplot(y=y_array, x=x_array)
58+
# to avoid text output
59+
plt.show()
60+
61+
62+
.. rst-class:: sphx-glr-timing
63+
64+
**Total running time of the script:** ( 0 minutes 0.000 seconds)
65+
66+
67+
.. _sphx_glr_download_built_examples_sample.py:
68+
69+
.. only:: html
70+
71+
.. container:: sphx-glr-footer sphx-glr-footer-example
72+
73+
74+
.. container:: sphx-glr-download sphx-glr-download-python
75+
76+
:download:`Download Python source code: sample.py <sample.py>`
77+
78+
.. container:: sphx-glr-download sphx-glr-download-jupyter
79+
80+
:download:`Download Jupyter notebook: sample.ipynb <sample.ipynb>`
81+
82+
83+
.. only:: html
84+
85+
.. rst-class:: sphx-glr-signature
86+
87+
`Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_

0 commit comments

Comments
 (0)