Skip to content

Commit 1a4cee4

Browse files
committed
Check tutorials with black and isort
1 parent 691692b commit 1a4cee4

File tree

5 files changed

+54
-34
lines changed

5 files changed

+54
-34
lines changed

.github/workflows/static_analysis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ jobs:
2929
pip install black
3030
pip install "black[jupyter]"
3131
black --check src/
32+
black --check tutorials/
3233
3334
- name: Code formatting with isort
3435
run: |
3536
pip install isort
3637
isort --check src/
38+
isort --check tutorials/
3739
3840
- name: Code formatting with prospector
3941
continue-on-error: true

tutorials/tutorial_03.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import maxplotlib.canvas.canvas as canvas
22

33
c = canvas.Canvas(width=2000, ratio=0.5)
4-
sp = c.add_subplot(grid=False, xlabel='(x - 10) * 0.1', ylabel='10y',yscale=10,xshift=-10,xscale=0.1)
5-
sp.add_line([0, 1, 2, 3], [0, 1, 4, 9], label="Line 1",layer=0)
6-
sp.add_line([0, 1, 2, 3], [0, 2, 3, 4], linestyle='dashed', color='red', label="Line 2",layer=1)
7-
#c.plot()
8-
c.savefig(layer_by_layer=True, filename='figures/tutorial_03_figure_01.pdf')
4+
sp = c.add_subplot(
5+
grid=False, xlabel="(x - 10) * 0.1", ylabel="10y", yscale=10, xshift=-10, xscale=0.1
6+
)
7+
sp.add_line([0, 1, 2, 3], [0, 1, 4, 9], label="Line 1", layer=0)
8+
sp.add_line(
9+
[0, 1, 2, 3], [0, 2, 3, 4], linestyle="dashed", color="red", label="Line 2", layer=1
10+
)
11+
# c.plot()
12+
c.savefig(layer_by_layer=True, filename="figures/tutorial_03_figure_01.pdf")

tutorials/tutorial_04.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,21 @@
1010
tikz = c.add_tikzfigure(grid=False)
1111

1212
# Add nodes
13-
tikz.add_node(0, 0, 'A', shape='circle', draw='black', fill='blue', layer=0)
14-
tikz.add_node(10, 0, 'B', shape='circle', draw='black', fill='blue', layer=0)
15-
tikz.add_node(10, 10, 'C', shape='circle', draw='black', fill='blue', layer=0)
16-
tikz.add_node(0, 10, 'D', shape='circle', draw='black', fill='blue', layer=2)
17-
18-
19-
# Add a line between nodes
20-
tikz.add_path(['A', 'B', 'C', 'D'], path_actions=['draw', 'rounded corners'], fill='red', opacity=0.5,cycle=True, layer=1)
13+
tikz.add_node(0, 0, "A", shape="circle", draw="black", fill="blue", layer=0)
14+
tikz.add_node(10, 0, "B", shape="circle", draw="black", fill="blue", layer=0)
15+
tikz.add_node(10, 10, "C", shape="circle", draw="black", fill="blue", layer=0)
16+
tikz.add_node(0, 10, "D", shape="circle", draw="black", fill="blue", layer=2)
17+
18+
19+
# Add a line between nodes
20+
tikz.add_path(
21+
["A", "B", "C", "D"],
22+
path_actions=["draw", "rounded corners"],
23+
fill="red",
24+
opacity=0.5,
25+
cycle=True,
26+
layer=1,
27+
)
2128

2229
raw_tikz = r"""
2330
\foreach \i in {0, 45, 90, 135, 180, 225, 270, 315} {
@@ -33,11 +40,11 @@
3340

3441
tikz.add_raw(raw_tikz)
3542

36-
tikz.add_node(0.5, 0.5, content='Cube', layer=10)
43+
tikz.add_node(0.5, 0.5, content="Cube", layer=10)
3744

3845
# Generate the TikZ script
3946
script = tikz.generate_tikz()
4047
print(script)
41-
#print(tikz.generate_standalone())
42-
tikz.compile_pdf('figures/tutorial_04_figure_01.pdf')
43-
#
48+
# print(tikz.generate_standalone())
49+
tikz.compile_pdf("figures/tutorial_04_figure_01.pdf")
50+
#

tutorials/tutorial_05.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
import maxplotlib.canvas.canvas as canvas
21
import numpy as np
32

3+
import maxplotlib.canvas.canvas as canvas
4+
45
c = canvas.Canvas(width=2000, ratio=0.5)
5-
sp = c.add_subplot(grid=True, xlabel='x', ylabel='y')
6+
sp = c.add_subplot(grid=True, xlabel="x", ylabel="y")
67

7-
node_a = sp.add_node(0, 0, 'A', content='Node A', shape='circle', draw='black', fill='blue!20')
8-
node_b = sp.add_node(1, 1, 'B', content='Node B', shape='circle', draw='black', fill='blue!20')
9-
#sp.add_node(2, 2, 'B', content="$a^2 + b^2 = c^2$", shape='rectangle', draw='red', fill='white', layer=1)
10-
#sp.add_node(2, 5, 'C', shape='rectangle', draw='red', fill='red')
11-
#last_node = sp.add_node(-1, 5, shape='rectangle', draw='red', fill='red', layer=-10)
8+
node_a = sp.add_node(
9+
0, 0, "A", content="Node A", shape="circle", draw="black", fill="blue!20"
10+
)
11+
node_b = sp.add_node(
12+
1, 1, "B", content="Node B", shape="circle", draw="black", fill="blue!20"
13+
)
14+
# sp.add_node(2, 2, 'B', content="$a^2 + b^2 = c^2$", shape='rectangle', draw='red', fill='white', layer=1)
15+
# sp.add_node(2, 5, 'C', shape='rectangle', draw='red', fill='red')
16+
# last_node = sp.add_node(-1, 5, shape='rectangle', draw='red', fill='red', layer=-10)
1217

13-
# Add a line between nodes
14-
sp.add_path(['A', 'B'], color='green', style='solid', line_width='2',layer=-5)
18+
# Add a line between nodes
19+
sp.add_path(["A", "B"], color="green", style="solid", line_width="2", layer=-5)
1520

16-
x = np.arange(0,2 * np.pi, 0.01)
21+
x = np.arange(0, 2 * np.pi, 0.01)
1722
y = np.sin(x)
1823
sp.add_line(x, y, label=r"$\sin(x)$")
1924
# c.plot()
20-
c.savefig(filename='figures/tutorial_05_figure_01.pdf')
25+
c.savefig(filename="figures/tutorial_05_figure_01.pdf")

tutorials/tutorial_06.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import matplotlib.pyplot as plt
12
import numpy as np
3+
24
import maxplotlib.canvas.canvas as canvas
3-
import matplotlib.pyplot as plt
5+
46
c = canvas.Canvas(width=2000, ratio=0.5)
5-
sp = c.add_subplot(grid=False, xlabel='x', ylabel='y')
7+
sp = c.add_subplot(grid=False, xlabel="x", ylabel="y")
68
# sp.add_line([0, 1, 2, 3], [0, 1, 4, 9], label="Line 1",layer=1)
7-
data = np.random.random((10,10))
8-
sp.add_imshow(data, extent=[1,10,1,20],layer=1)
9-
#c.plot()
10-
c.savefig(layer_by_layer=True, filename='figures/tutorial_06_figure_01.pdf')
9+
data = np.random.random((10, 10))
10+
sp.add_imshow(data, extent=[1, 10, 1, 20], layer=1)
11+
# c.plot()
12+
c.savefig(layer_by_layer=True, filename="figures/tutorial_06_figure_01.pdf")

0 commit comments

Comments
 (0)