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

Pep8 naming partial compliance #70

Merged
merged 3 commits into from
Jun 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

# Applied `pre-commit` `end-of-file-fixer`
e9104b3616899f54257bb38959d6e1c0acc70f6a

# Applied `ruff` `pep8-naming` rules
1eb35bbb81a8f3f72cf5c2cb44d3dd94d4c15c32
19 changes: 18 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,24 @@ target-version = ["py38", "py39", "py310", "py311"]

[tool.ruff]
target-version = "py38"
select = ["F", "E", "W", "C90", "I", "UP", "YTT", "B", "A", "C4", "T10", "RUF"]
select = [
"F",
"E",
"W",
"C90",
"I",
"N",
"UP",
"YTT",
"B",
"A",
"C4",
"T10",
"RUF",
]

[tool.ruff.per-file-ignores]
"viscm/gui.py" = ["N8"]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is going to be a can of worms to apply pep8 naming conventions to. I think as this file is the largest by far in the repo, it will likely be slowly refactored into different modules over time as the need arises, and maybe as each small module gets extracted can have pep8 naming conventions applied at that time.


[tool.ruff.mccabe]
max-complexity = 11
16 changes: 8 additions & 8 deletions viscm/bezierbuilder/curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from scipy.special import binom


def Bernstein(n, k):
def bernstein(n, k):
"""Bernstein polynomial."""
coeff = binom(n, k)

Expand All @@ -14,7 +14,7 @@ def _bpoly(x):
return _bpoly


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

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


def CatmulClark(points, at):
def catmul_clark(points, at):
points = np.asarray(points)

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


curve_method = {
"Bezier": Bezier,
"CatmulClark": CatmulClark,
"Bezier": bezier,
"CatmulClark": catmul_clark,
}
12 changes: 6 additions & 6 deletions viscm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ def cli():
if cm is None:
sys.exit("Please specify a colormap")
fig = plt.figure()
figureCanvas = gui.FigureCanvas(fig)
figure_canvas = gui.FigureCanvas(fig)
v = gui.viscm(cm.cmap, name=cm.name, figure=fig, uniform_space=cm.uniform_space)
mainwindow = gui.ViewerWindow(figureCanvas, v, cm.name)
mainwindow = gui.ViewerWindow(figure_canvas, v, cm.name)
if args.save is not None:
v.figure.set_size_inches(20, 12)
v.figure.savefig(args.save)
Expand All @@ -103,25 +103,25 @@ def cli():
sys.exit("Sorry, I don't know how to edit the specified colormap")
# Hold a reference so it doesn't get GC'ed
fig = plt.figure()
figureCanvas = gui.FigureCanvas(fig)
figure_canvas = gui.FigureCanvas(fig)
v = gui.viscm_editor(
figure=fig,
uniform_space=cm.uniform_space,
cmtype=cm.cmtype,
method=cm.method,
**cm.params,
)
mainwindow = gui.EditorWindow(figureCanvas, v)
mainwindow = gui.EditorWindow(figure_canvas, v)
else:
raise RuntimeError("can't happen")

if args.quit:
sys.exit()

figureCanvas.setSizePolicy(
figure_canvas.setSizePolicy(
gui.QtWidgets.QSizePolicy.Expanding, gui.QtWidgets.QSizePolicy.Expanding
)
figureCanvas.updateGeometry()
figure_canvas.updateGeometry()

mainwindow.resize(800, 600)
mainwindow.show()
Expand Down