Skip to content

Commit 46d3989

Browse files
authored
Merge pull request #70 from mfisher87/pep8-naming
Pep8 naming partial compliance
2 parents 6215af7 + 7abd220 commit 46d3989

File tree

4 files changed

+35
-15
lines changed

4 files changed

+35
-15
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33

44
# Applied `pre-commit` `end-of-file-fixer`
55
e9104b3616899f54257bb38959d6e1c0acc70f6a
6+
7+
# Applied `ruff` `pep8-naming` rules
8+
1eb35bbb81a8f3f72cf5c2cb44d3dd94d4c15c32

pyproject.toml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,24 @@ target-version = ["py38", "py39", "py310", "py311"]
5050

5151
[tool.ruff]
5252
target-version = "py38"
53-
select = ["F", "E", "W", "C90", "I", "UP", "YTT", "B", "A", "C4", "T10", "RUF"]
53+
select = [
54+
"F",
55+
"E",
56+
"W",
57+
"C90",
58+
"I",
59+
"N",
60+
"UP",
61+
"YTT",
62+
"B",
63+
"A",
64+
"C4",
65+
"T10",
66+
"RUF",
67+
]
68+
69+
[tool.ruff.per-file-ignores]
70+
"viscm/gui.py" = ["N8"]
5471

5572
[tool.ruff.mccabe]
5673
max-complexity = 11

viscm/bezierbuilder/curve.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from scipy.special import binom
55

66

7-
def Bernstein(n, k):
7+
def bernstein(n, k):
88
"""Bernstein polynomial."""
99
coeff = binom(n, k)
1010

@@ -14,7 +14,7 @@ def _bpoly(x):
1414
return _bpoly
1515

1616

17-
def Bezier(points, at):
17+
def bezier(points, at):
1818
"""Build Bézier curve from points."""
1919
warnings.warn(
2020
message="Deprecated. CatmulClark builds nicer splines.",
@@ -24,14 +24,14 @@ def Bezier(points, at):
2424

2525
at = np.asarray(at)
2626
at_flat = at.ravel()
27-
N = len(points)
27+
n = len(points)
2828
curve = np.zeros((at_flat.shape[0], 2))
29-
for ii in range(N):
30-
curve += np.outer(Bernstein(N - 1, ii)(at_flat), points[ii])
29+
for ii in range(n):
30+
curve += np.outer(bernstein(n - 1, ii)(at_flat), points[ii])
3131
return curve.reshape((*at.shape, 2))
3232

3333

34-
def CatmulClark(points, at):
34+
def catmul_clark(points, at):
3535
points = np.asarray(points)
3636

3737
while len(points) < len(at):
@@ -48,6 +48,6 @@ def CatmulClark(points, at):
4848

4949

5050
curve_method = {
51-
"Bezier": Bezier,
52-
"CatmulClark": CatmulClark,
51+
"Bezier": bezier,
52+
"CatmulClark": catmul_clark,
5353
}

viscm/cli.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ def cli():
9292
if cm is None:
9393
sys.exit("Please specify a colormap")
9494
fig = plt.figure()
95-
figureCanvas = gui.FigureCanvas(fig)
95+
figure_canvas = gui.FigureCanvas(fig)
9696
v = gui.viscm(cm.cmap, name=cm.name, figure=fig, uniform_space=cm.uniform_space)
97-
mainwindow = gui.ViewerWindow(figureCanvas, v, cm.name)
97+
mainwindow = gui.ViewerWindow(figure_canvas, v, cm.name)
9898
if args.save is not None:
9999
v.figure.set_size_inches(20, 12)
100100
v.figure.savefig(args.save)
@@ -103,25 +103,25 @@ def cli():
103103
sys.exit("Sorry, I don't know how to edit the specified colormap")
104104
# Hold a reference so it doesn't get GC'ed
105105
fig = plt.figure()
106-
figureCanvas = gui.FigureCanvas(fig)
106+
figure_canvas = gui.FigureCanvas(fig)
107107
v = gui.viscm_editor(
108108
figure=fig,
109109
uniform_space=cm.uniform_space,
110110
cmtype=cm.cmtype,
111111
method=cm.method,
112112
**cm.params,
113113
)
114-
mainwindow = gui.EditorWindow(figureCanvas, v)
114+
mainwindow = gui.EditorWindow(figure_canvas, v)
115115
else:
116116
raise RuntimeError("can't happen")
117117

118118
if args.quit:
119119
sys.exit()
120120

121-
figureCanvas.setSizePolicy(
121+
figure_canvas.setSizePolicy(
122122
gui.QtWidgets.QSizePolicy.Expanding, gui.QtWidgets.QSizePolicy.Expanding
123123
)
124-
figureCanvas.updateGeometry()
124+
figure_canvas.updateGeometry()
125125

126126
mainwindow.resize(800, 600)
127127
mainwindow.show()

0 commit comments

Comments
 (0)