Skip to content

Commit e903b59

Browse files
committed
Output images
1 parent fd39727 commit e903b59

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
name: Master Only
1+
name: Examples
22

33
on:
44
pull_request:
5+
paths:
6+
- 'examples/*.py'
7+
- 'notebooks/*.ipynb'
58
push:
69
branches:
710
- master
811

912
jobs:
1013
examples:
11-
name: Examples
1214
runs-on: ubuntu-latest
1315
steps:
1416
- uses: actions/checkout@v1
@@ -18,10 +20,12 @@ jobs:
1820
with:
1921
python-version: '3.8.0'
2022
- name: Pre-install Numpy
21-
run: python -m pip install numpy nbconvert
23+
run: python -m pip install numpy nbconvert ipykernel
24+
- name: Install kernel
25+
run: python -m ipykernel install --user --name boost-hist
2226
- name: Build
2327
run: python -m pip install .[examples]
2428
- name: Examples
2529
run: for f in examples/*.py; do python "$f"; done
2630
- name: Notebooks
27-
run: nbconvert --execute --inplace notebooks/*.ipynb
31+
run: jupyter nbconvert --execute --inplace notebooks/*.ipynb

.github/workflows/pre-commit.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
name: Format
1+
name: Tests
22

33
on:
44
pull_request:
5+
branches:
6+
- master
7+
- develop
58
push:
69
branches:
710
- master
811
- develop
912

1013
jobs:
1114
pre-commit:
15+
name: Format
1216
runs-on: ubuntu-latest
1317
steps:
1418
- uses: actions/checkout@v1

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
/*build*
3636
/docs/_build/*
3737

38+
# Outputs
39+
/examples/*.png
40+
*.pkl
41+
3842
# Python binary files
3943
*.pyc
4044
*__pycache__*

examples/simple_2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@
2727
ax.set_xlabel(h.axes[0].metadata)
2828
ax.set_ylabel(h.axes[1].metadata)
2929
ax.set_aspect("equal")
30-
plt.show()
30+
plt.savefig("simple_2d.png")

examples/simple_density.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
# Compute the density
1717
density = hist.view() / hist.sum() / areas
1818

19-
# pcolormesh requires fully broadcast arrays for ij indexing, sadly, so get the
20-
# edges (50x1 and 1x50 arrays) and broadcast them out to 50x50.
21-
X, Y = np.broadcast_arrays(*hist.axes.edges)
19+
# Get the edges
20+
X, Y = hist.axes.edges
2221

22+
# Make the plot
2323
fig, ax = plt.subplots()
24-
mesh = ax.pcolormesh(X, Y, density)
24+
mesh = ax.pcolormesh(X.T, Y.T, density.T)
2525
fig.colorbar(mesh)
26-
plt.show()
26+
plt.savefig("simple_density.png")

examples/simple_numpy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@
2828
plt.pcolor(x, y, count_matrix.T)
2929
plt.xlabel(h.axes[0].metadata)
3030
plt.ylabel(h.axes[1].metadata)
31-
plt.show()
31+
plt.savefig("simple_numpy.png")

0 commit comments

Comments
 (0)