Skip to content

Commit

Permalink
Incorporate examples from the docs in the gallery (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
alcarney authored Jun 18, 2020
1 parent 01094c3 commit 8f3aa85
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/blog-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,31 @@ jobs:
python --version
python -m pip install --upgrade pip
python -m pip install --pre arlunio
python -m pip install .
python -m pip install -r blog/requirements.txt
# </build-job-setup>

# <build-job-blog>
- name: Build Gallery
run: |
cd blog
cd docs
make nbgallery
ls -1 _build/nbgallery/examples/
cp _build/nbgallery/examples/*.ipynb ../blog/src/gallery
cd ../blog
python gallery.py
# </build-job-blog>

# <build-job-deploy>
- name: Publish Release Artifact
uses: actions/[email protected]
with:
name: 'blog'
path: blog/public
if: github.event_name == 'pull_request'

- name: Deploy
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
Expand Down
2 changes: 1 addition & 1 deletion arlunio/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.7"
__version__ = "0.10.0"
15 changes: 11 additions & 4 deletions arlunio/pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ def Grid(width: int, height: int, *, n=4, m=None, defn=None) -> Mask:
Examples
--------
.. arlunio-image:: Grid Example
.. arlunio-image:: Circular Pattern
:include-code:
:gallery: examples
A pattern generated from circles::
Expand Down Expand Up @@ -156,6 +157,8 @@ def Map(width: int, height: int, *, layout=None, legend=None) -> Mask:
-------
.. arlunio-image:: Simple Map
:include-code:
:width: 50%
:gallery: examples
::
Expand Down Expand Up @@ -205,7 +208,7 @@ def Wall(width: int, height: int, *, sides=None):
])
map_ = Map(legend=legend, layout=layout)
image = fill(map_(width=256, height=256), color="blue")
image = fill(map_(width=1080, height=1080), color="blue")
"""

# TODO: Handle divisions with rounding errors
Expand All @@ -226,6 +229,7 @@ def Pixelize(
) -> Mask:
"""
.. arlunio-image:: Pixelise
:align: center
Draw a pixelated version of a definition::
Expand Down Expand Up @@ -270,8 +274,9 @@ def Pixelize(
.. arlunio-image:: Simple Pixelise
:include-code:
:width: 50%
This definition can be used to render a simple picel patter at a higher
This definition can be used to render a simple pixel pattern at a higher
resolution::
import numpy as np
Expand All @@ -291,6 +296,8 @@ def Pixelize(
.. arlunio-image:: Ghost
:include-code:
:width: 50%
:gallery: examples
We can also generate the pixels from an instance of another definition::
Expand All @@ -317,7 +324,7 @@ def Ghost(x: X, y: Y):
return (head(x=x, y=y) - eyes(x=np.abs(x), y=y)) + body
ghost = Pixelize(defn=Ghost(y0=-0.3), n=32, m=32)
image = fill(ghost(width=512, height=512), color="#f00")
image = fill(ghost(width=1080, height=1080), color="#f00")
"""

if defn is None and pixels is None:
Expand Down
7 changes: 6 additions & 1 deletion arlunio/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def Circle(x: X, y: Y, *, xc=0, yc=0, r=0.8, pt=None) -> Mask:
:include-code:
:gallery: examples
Combining a few circles it's easy enough to draw a target::
Combining a few circles we're able to draw a target::
import arlunio as ar
Expand Down Expand Up @@ -83,6 +83,7 @@ def Target(width: int, height: int):
.. arlunio-image:: Olympic Rings
:include-code:
:gallery: examples
::
Expand Down Expand Up @@ -217,6 +218,7 @@ def EllipseDemo(width: int, height: int):
.. arlunio-image:: Atom
:include-code:
:gallery: examples
Playing around with the values and the coordinate inputs it's possible to
draw something that looks like a diagram of an atom::
Expand Down Expand Up @@ -327,6 +329,7 @@ def SuperEllipse(
.. arlunio-image:: SuperEllipse Demo
:include-code:
:gallery: examples
::
Expand Down Expand Up @@ -362,6 +365,7 @@ def SuperEllipseDemo(width: int, height: int):
.. arlunio-image:: Eye of Sauron
:include-code:
:gallery: examples
"Eye of Sauron"::
Expand Down Expand Up @@ -443,6 +447,7 @@ def Square(x: X, y: Y, *, xc=0, yc=0, size=0.8, pt=None) -> Mask:
.. arlunio-image:: Square Demo
:include-code:
:gallery: examples
::
Expand Down
3 changes: 2 additions & 1 deletion blog/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ jupyter
jinja2
markdown
pygments
sphinx
tomlkit
tqdm
tqdm

0 comments on commit 8f3aa85

Please sign in to comment.