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

[WIP] sphinx-gallery #14

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2129c82
sphinx-gallery
t-makaro Sep 19, 2018
7466813
add pillow to docs/requirements/txt
t-makaro Sep 19, 2018
2ddb039
upload source in doc build]
t-makaro Sep 19, 2018
83d84e1
don't use sphinx 1.8
t-makaro Sep 19, 2018
8d5cba7
install package for doc build
t-makaro Sep 19, 2018
f054c4f
setup.py install for docs not tests
t-makaro Sep 19, 2018
77a3232
attempt to properly run setup.py
t-makaro Sep 19, 2018
df5df2a
pip install for circleci doc build
t-makaro Sep 19, 2018
e66b2a1
use matplotlib 3.0 default on matplotlib 2.2
t-makaro Sep 20, 2018
077c10f
Merge pull request #18 from t-makaro/tests
t-makaro Sep 20, 2018
79a518f
sphinx-gallery
t-makaro Sep 19, 2018
3b1a8a5
add pillow to docs/requirements/txt
t-makaro Sep 19, 2018
d82e122
upload source in doc build]
t-makaro Sep 19, 2018
c75f723
don't use sphinx 1.8
t-makaro Sep 19, 2018
dc78675
install package for doc build
t-makaro Sep 19, 2018
983b665
setup.py install for docs not tests
t-makaro Sep 19, 2018
c50f27d
attempt to properly run setup.py
t-makaro Sep 19, 2018
be430eb
pip install for circleci doc build
t-makaro Sep 19, 2018
892c623
Merge branch 'gallery' of https://github.com/t-makaro/animatplot into…
t-makaro Sep 20, 2018
ef5e74f
remove manual tag
t-makaro Sep 22, 2018
6918668
update gitignore
t-makaro Sep 22, 2018
9c1c501
always default to build gallery
t-makaro Sep 22, 2018
ef8be1a
test with both images
t-makaro Sep 22, 2018
d32a379
use imagemagick
t-makaro Sep 22, 2018
0f065d3
use pillow again
t-makaro Sep 22, 2018
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
5 changes: 5 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ instance/
# Sphinx documentation
docs/_build/
docs/source/_as_gen
docs/source/auto_examples

# PyBuilder
target/
Expand Down Expand Up @@ -98,3 +99,6 @@ ENV/

# vscode reST doc preview
_build

# examples
examples/*.gif
6 changes: 6 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build:
image: 2.0

python:
version: 3.5
setup_py_install: true
5 changes: 4 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
17 changes: 10 additions & 7 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ animatplot
tutorial/tutorial
api
gallery
auto_examples/index

.. toctree::
:maxdepth: 1
Expand Down
4 changes: 4 additions & 0 deletions examples/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This is my gallery
==================

Below is a gallery of examples
48 changes: 48 additions & 0 deletions examples/plot_sqwell.py
Original file line number Diff line number Diff line change
@@ -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()
Binary file modified tests/baseline_images/Blocks/Nuke0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/baseline_images/Blocks/Nuke1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/baseline_images/Blocks/Nuke2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tests/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])