flake8 fixup

This commit is contained in:
Jan Petykiewicz 2024-07-18 00:17:45 -07:00
parent a94c2cae67
commit 3e4e6eead3
5 changed files with 38 additions and 10 deletions

29
.flake8 Normal file
View File

@ -0,0 +1,29 @@
[flake8]
ignore =
# E501 line too long
E501,
# W391 newlines at EOF
W391,
# E241 multiple spaces after comma
E241,
# E302 expected 2 newlines
E302,
# W503 line break before binary operator (to be deprecated)
W503,
# E265 block comment should start with '# '
E265,
# E123 closing bracket does not match indentation of opening bracket's line
E123,
# E124 closing bracket does not match visual indentation
E124,
# E221 multiple spaces before operator
E221,
# E201 whitespace after '['
E201,
# E741 ambiguous variable name 'I'
E741,
per-file-ignores =
# F401 import without use
*/__init__.py: F401,

View File

@ -113,7 +113,7 @@ def draw_polygons(
foregrounds_i = foregrounds[i] foregrounds_i = foregrounds[i]
if callable(foregrounds_i): if callable(foregrounds_i):
# meshgrid over the (shifted) domain # meshgrid over the (shifted) domain
domain = [self.shifted_xyz(i)[k][bdi_min[k]:bdi_max[k]+1] for k in range(3)] domain = [self.shifted_xyz(i)[k][bdi_min[k]:bdi_max[k] + 1] for k in range(3)]
(x0, y0, z0) = numpy.meshgrid(*domain, indexing='ij') (x0, y0, z0) = numpy.meshgrid(*domain, indexing='ij')
# evaluate on the meshgrid # evaluate on the meshgrid
@ -319,7 +319,7 @@ def draw_cylinder(
num_points: The circle is approximated by a polygon with `num_points` vertices num_points: The circle is approximated by a polygon with `num_points` vertices
foreground: Value to draw with ('brush color'). See `draw_polygons()` for details. foreground: Value to draw with ('brush color'). See `draw_polygons()` for details.
""" """
theta = numpy.linspace(0, 2*numpy.pi, num_points, endpoint=False) theta = numpy.linspace(0, 2 * numpy.pi, num_points, endpoint=False)
x = radius * numpy.sin(theta) x = radius * numpy.sin(theta)
y = radius * numpy.cos(theta) y = radius * numpy.cos(theta)
polygon = numpy.hstack((x[:, None], y[:, None])) polygon = numpy.hstack((x[:, None], y[:, None]))
@ -360,8 +360,8 @@ def draw_extrude_rectangle(
surface = numpy.delete(range(3), direction) surface = numpy.delete(range(3), direction)
dim = numpy.fabs(numpy.diff(rectangle, axis=0).T)[surface] dim = numpy.fabs(numpy.diff(rectangle, axis=0).T)[surface]
p = numpy.vstack((numpy.array([-1, -1, 1, 1], dtype=float) * dim[0]/2.0, p = numpy.vstack((numpy.array([-1, -1, 1, 1], dtype=float) * dim[0] * 0.5,
numpy.array([-1, 1, 1, -1], dtype=float) * dim[1]/2.0)).T numpy.array([-1, 1, 1, -1], dtype=float) * dim[1] * 0.5)).T
thickness = distance thickness = distance
foreground_func = [] foreground_func = []
@ -371,7 +371,7 @@ def draw_extrude_rectangle(
ind = [int(numpy.floor(z)) if i == direction else slice(None) for i in range(3)] ind = [int(numpy.floor(z)) if i == direction else slice(None) for i in range(3)]
fpart = z - numpy.floor(z) fpart = z - numpy.floor(z)
mult = [1-fpart, fpart][::s] # reverses if s negative mult = [1 - fpart, fpart][::s] # reverses if s negative
foreground = mult[0] * grid[tuple(ind)] foreground = mult[0] * grid[tuple(ind)]
ind[direction] += 1 # type: ignore #(known safe) ind[direction] += 1 # type: ignore #(known safe)

View File

@ -2,7 +2,6 @@ from typing import Callable, Sequence, ClassVar, Self
import numpy import numpy
from numpy.typing import NDArray, ArrayLike from numpy.typing import NDArray, ArrayLike
from numpy import diff, floor, ceil, zeros, hstack, newaxis
import pickle import pickle
import warnings import warnings

View File

@ -4,7 +4,7 @@ Readback and visualization methods for Grid class
from typing import Any, TYPE_CHECKING from typing import Any, TYPE_CHECKING
import numpy import numpy
from numpy.typing import NDArray, ArrayLike from numpy.typing import NDArray
from . import GridError from . import GridError