diff --git a/.circleci/config.yml b/.circleci/config.yml index eff1b0f..1b22521 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -44,10 +44,15 @@ jobs: - run: *apt-install - run: *doc-deps + - run: + name: Setup.py + command: pip install --user -e . - run: *doc-build - store_artifacts: path: docs/build/html + - store_artifacts: + path: docs/source test-python36: docker: diff --git a/.gitignore b/.gitignore index 1962ea9..bdcec7d 100644 --- a/.gitignore +++ b/.gitignore @@ -64,6 +64,7 @@ instance/ # Sphinx documentation docs/_build/ docs/source/_as_gen +docs/source/auto_examples # PyBuilder target/ @@ -98,3 +99,6 @@ ENV/ # vscode reST doc preview _build + +# examples +examples/*.gif diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000..cfb7243 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,6 @@ +build: + image: 2.0 + +python: + version: 3.5 + setup_py_install: true \ No newline at end of file diff --git a/docs/requirements.txt b/docs/requirements.txt index 26b05b9..68a3792 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,6 +1,9 @@ -sphinx>=1.5.1 +sphinx<1.8 ipykernel nbsphinx matplotlib>=2.2 sphinx_rtd_theme +pillow +#https://api.github.com/repos/sphinx-gallery/sphinx-gallery/zipball/master +git+https://github.com/choldgraf/sphinx-gallery.git@scraper numpy \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py index 9c0f540..5570ab9 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -52,15 +52,18 @@ 'sphinx.ext.mathjax', 'sphinx.ext.viewcode', 'nbsphinx', - # 'sphinx_gallery.gen_gallery', + 'sphinx_gallery.gen_gallery', ] -# sphinx_gallery_conf = { -# # path to your examples scripts -# 'examples_dirs': '../../examples', -# # path where to save gallery generated examples -# 'gallery_dirs': 'auto_examples', -# } + +sphinx_gallery_conf = { + # path to your examples scripts + 'plot_gallery': 'True', + 'examples_dirs': '../../examples', + # path where to save gallery generated examples + 'gallery_dirs': 'auto_examples', + 'image_scrapers': ('image_files') +} # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/docs/source/index.rst b/docs/source/index.rst index 47d6a56..e9cde86 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -18,6 +18,7 @@ animatplot tutorial/tutorial api gallery + auto_examples/index .. toctree:: :maxdepth: 1 diff --git a/examples/README.txt b/examples/README.txt new file mode 100644 index 0000000..9b6344f --- /dev/null +++ b/examples/README.txt @@ -0,0 +1,4 @@ +This is my gallery +================== + +Below is a gallery of examples \ No newline at end of file diff --git a/examples/plot_sqwell.py b/examples/plot_sqwell.py new file mode 100644 index 0000000..3efb0ae --- /dev/null +++ b/examples/plot_sqwell.py @@ -0,0 +1,48 @@ +""" +Square Well +=========== + +.. image:: plot_sqwell.gif +""" +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.animation import PillowWriter, FFMpegWriter +import animatplot as aplt + + +def psi(x, t): + return (2**-.5*np.exp(t*1j)*np.sin(np.pi*x) + + .5*np.exp(t*4j)*np.sin(2*np.pi*x) + + .5*np.exp(t*9j)*np.sin(3*np.pi*x)) + + +x = np.linspace(0, 1, 20) +t = np.linspace(0, 10, 20) + +X, T = np.meshgrid(x, t) +Y1 = psi(X, T).real +Y2 = psi(X, T).imag + +timeline = aplt.Timeline(t, 's', 24) + +ax = plt.axes(xlim=[0, 1], ylim=[-2, 2]) +block1 = aplt.blocks.Line(X, Y1, ax) +block2 = aplt.blocks.Line(X, Y2, ax) + +anim = aplt.Animation([block1, block2], timeline) + +# Your standard matplotlib stuff +plt.title(r'Particle in a Box: $|\Psi\rangle = \frac{1}{\sqrt{2}}' + r'|E_1\rangle + \frac{1}{2}|E_2\rangle + \frac{1}{2}|E_3\rangle$', + y=1.03) +plt.xlabel('position') +plt.ylabel(r'$\Psi$') +plt.legend(['Real', 'Imaginary']) + +anim.toggle() +anim.timeline_slider() + +# anim.save('sq_well.mp4', writer=FFMpegWriter(fps=5)) +anim.save('plot_sqwell.gif', writer=PillowWriter(fps=5)) +# anim.animation.save('plot_sqwell.gif', writer='imagemagick') +plt.show() diff --git a/tests/baseline_images/Blocks/Nuke0.png b/tests/baseline_images/Blocks/Nuke0.png index 12987a1..29570f0 100644 Binary files a/tests/baseline_images/Blocks/Nuke0.png and b/tests/baseline_images/Blocks/Nuke0.png differ diff --git a/tests/baseline_images/Blocks/Nuke1.png b/tests/baseline_images/Blocks/Nuke1.png index 5366003..2bfb012 100644 Binary files a/tests/baseline_images/Blocks/Nuke1.png and b/tests/baseline_images/Blocks/Nuke1.png differ diff --git a/tests/baseline_images/Blocks/Nuke2.png b/tests/baseline_images/Blocks/Nuke2.png index 6879d82..e729cd4 100644 Binary files a/tests/baseline_images/Blocks/Nuke2.png and b/tests/baseline_images/Blocks/Nuke2.png differ diff --git a/tests/test_blocks.py b/tests/test_blocks.py index 3056435..cf49d07 100644 --- a/tests/test_blocks.py +++ b/tests/test_blocks.py @@ -63,6 +63,7 @@ def test_Nuke(): def animate(i): sizes.append(i+1) + ax.set_aspect("equal") ax.pie(sizes) block = amp.blocks.Nuke(animate, length=3, ax=ax) return amp.Animation([block])