Cosmetic changes to argument lists

lethe/HEAD
Jan Petykiewicz 5 years ago
parent 58353b7884
commit 16c6bfc70a

@ -94,10 +94,10 @@ class Pattern:
return self
def subset(self,
shapes_func: Callable[[Shape], bool]=None,
labels_func: Callable[[Label], bool]=None,
subpatterns_func: Callable[[SubPattern], bool]=None,
recursive: bool=False,
shapes_func: Callable[[Shape], bool] = None,
labels_func: Callable[[Label], bool] = None,
subpatterns_func: Callable[[SubPattern], bool] = None,
recursive: bool = False,
) -> 'Pattern':
"""
Returns a Pattern containing only the entities (e.g. shapes) for which the
@ -133,7 +133,7 @@ class Pattern:
def apply(self,
func: Callable[['Pattern'], 'Pattern'],
memo: Dict[int, 'Pattern']=None,
memo: Dict[int, 'Pattern'] = None,
) -> 'Pattern':
"""
Recursively apply func() to this pattern and any pattern it references.
@ -166,8 +166,8 @@ class Pattern:
return pat
def polygonize(self,
poly_num_points: int=None,
poly_max_arclen: float=None
poly_num_points: int = None,
poly_max_arclen: float = None,
) -> 'Pattern':
"""
Calls .to_polygons(...) on all the shapes in this Pattern and any referenced patterns,
@ -191,7 +191,7 @@ class Pattern:
def manhattanize(self,
grid_x: numpy.ndarray,
grid_y: numpy.ndarray
grid_y: numpy.ndarray,
) -> 'Pattern':
"""
Calls .polygonize() and .flatten on the pattern, then calls .manhattanize() on all the
@ -209,9 +209,9 @@ class Pattern:
return self
def subpatternize(self,
recursive: bool=True,
norm_value: int=1e6,
exclude_types: Tuple[Shape]=(Polygon,)
recursive: bool = True,
norm_value: int = int(1e6),
exclude_types: Tuple[Shape] = (Polygon,)
) -> 'Pattern':
"""
Iterates through this Pattern and all referenced Patterns. Within each Pattern, it iterates
@ -529,10 +529,10 @@ class Pattern:
return self
def visualize(self,
offset: vector2=(0., 0.),
line_color: str='k',
fill_color: str='none',
overdraw: bool=False):
offset: vector2 = (0., 0.),
line_color: str = 'k',
fill_color: str = 'none',
overdraw: bool = False):
"""
Draw a picture of the Pattern and wait for the user to inspect it

@ -140,13 +140,13 @@ class Arc(Shape):
radii: vector2,
angles: vector2,
width: float,
poly_num_points: int=DEFAULT_POLY_NUM_POINTS,
poly_max_arclen: float=None,
offset: vector2=(0.0, 0.0),
rotation: float=0,
poly_num_points: int = DEFAULT_POLY_NUM_POINTS,
poly_max_arclen: float = None,
offset: vector2 = (0.0, 0.0),
rotation: float = 0,
mirrored: Tuple[bool] = (False, False),
layer: int=0,
dose: float=1.0):
layer: int = 0,
dose: float = 1.0):
self.identifier = ()
self.radii = radii
self.angles = angles
@ -167,7 +167,10 @@ class Arc(Shape):
new._angles = self._angles.copy()
return new
def to_polygons(self, poly_num_points: int=None, poly_max_arclen: float=None) -> List[Polygon]:
def to_polygons(self,
poly_num_points: int = None,
poly_max_arclen: float = None,
) -> List[Polygon]:
if poly_num_points is None:
poly_num_points = self.poly_num_points
if poly_max_arclen is None:

@ -39,11 +39,11 @@ class Circle(Shape):
def __init__(self,
radius: float,
poly_num_points: int=DEFAULT_POLY_NUM_POINTS,
poly_max_arclen: float=None,
offset: vector2=(0.0, 0.0),
layer: int=0,
dose: float=1.0):
poly_num_points: int = DEFAULT_POLY_NUM_POINTS,
poly_max_arclen: float = None,
offset: vector2 = (0.0, 0.0),
layer: int = 0,
dose: float = 1.0):
self.identifier = ()
self.offset = numpy.array(offset, dtype=float)
self.layer = layer
@ -58,7 +58,10 @@ class Circle(Shape):
new._offset = self._offset.copy()
return new
def to_polygons(self, poly_num_points: int=None, poly_max_arclen: float=None) -> List[Polygon]:
def to_polygons(self,
poly_num_points: int = None,
poly_max_arclen: float = None,
) -> List[Polygon]:
if poly_num_points is None:
poly_num_points = self.poly_num_points
if poly_max_arclen is None:

@ -81,13 +81,13 @@ class Ellipse(Shape):
def __init__(self,
radii: vector2,
poly_num_points: int=DEFAULT_POLY_NUM_POINTS,
poly_max_arclen: float=None,
offset: vector2=(0.0, 0.0),
rotation: float=0,
poly_num_points: int = DEFAULT_POLY_NUM_POINTS,
poly_max_arclen: float = None,
offset: vector2 = (0.0, 0.0),
rotation: float = 0,
mirrored: Tuple[bool] = (False, False),
layer: int=0,
dose: float=1.0):
layer: int = 0,
dose: float = 1.0):
self.identifier = ()
self.radii = radii
self.offset = offset
@ -106,8 +106,8 @@ class Ellipse(Shape):
return new
def to_polygons(self,
poly_num_points: int=None,
poly_max_arclen: float=None
poly_num_points: int = None,
poly_max_arclen: float = None,
) -> List[Polygon]:
if poly_num_points is None:
poly_num_points = self.poly_num_points

@ -149,8 +149,8 @@ class Path(Shape):
offset: vector2 = (0.0, 0.0),
rotation: float = 0,
mirrored: Tuple[bool] = (False, False),
layer: int=0,
dose: float=1.0,
layer: int = 0,
dose: float = 1.0,
) -> 'Path':
self._cap_extensions = None # Since .cap setter might access it
@ -180,11 +180,11 @@ class Path(Shape):
width: float = 0.0,
cap: 'Path.Cap' = Cap.Flush,
cap_extensions = None,
offset: vector2=(0.0, 0.0),
offset: vector2 = (0.0, 0.0),
rotation: float = 0,
mirrored: Tuple[bool] = (False, False),
layer: int=0,
dose: float=1.0,
layer: int = 0,
dose: float = 1.0,
) -> 'Path':
"""
Build a path by specifying the turn angles and travel distances
@ -220,8 +220,8 @@ class Path(Shape):
layer=layer, dose=dose)
def to_polygons(self,
poly_num_points: int=None,
poly_max_arclen: float=None,
poly_num_points: int = None,
poly_max_arclen: float = None,
) -> List['Polygon']:
extensions = self._calculate_cap_extensions()

@ -72,11 +72,11 @@ class Polygon(Shape):
def __init__(self,
vertices: numpy.ndarray,
offset: vector2=(0.0, 0.0),
rotation: float=0.0,
offset: vector2 = (0.0, 0.0),
rotation: float = 0.0,
mirrored: Tuple[bool] = (False, False),
layer: int=0,
dose: float=1.0,
layer: int = 0,
dose: float = 1.0,
):
self.identifier = ()
self.layer = layer
@ -95,10 +95,10 @@ class Polygon(Shape):
@staticmethod
def square(side_length: float,
rotation: float=0.0,
offset: vector2=(0.0, 0.0),
layer: int=0,
dose: float=1.0
rotation: float = 0.0,
offset: vector2 = (0.0, 0.0),
layer: int = 0,
dose: float = 1.0,
) -> 'Polygon':
"""
Draw a square given side_length, centered on the origin.
@ -122,10 +122,10 @@ class Polygon(Shape):
@staticmethod
def rectangle(lx: float,
ly: float,
rotation: float=0,
offset: vector2=(0.0, 0.0),
layer: int=0,
dose: float=1.0
rotation: float = 0,
offset: vector2 = (0.0, 0.0),
layer: int = 0,
dose: float = 1.0,
) -> 'Polygon':
"""
Draw a rectangle with side lengths lx and ly, centered on the origin.
@ -156,7 +156,7 @@ class Polygon(Shape):
ymax: float = None,
ly: float = None,
layer: int = 0,
dose: float = 1.0
dose: float = 1.0,
) -> 'Polygon':
"""
Draw a rectangle by specifying side/center positions.
@ -222,8 +222,8 @@ class Polygon(Shape):
def to_polygons(self,
_poly_num_points: int=None,
_poly_max_arclen: float=None,
_poly_num_points: int = None,
_poly_max_arclen: float = None,
) -> List['Polygon']:
return [copy.deepcopy(self)]

@ -193,7 +193,10 @@ class Shape(metaclass=ABCMeta):
self.translate(+pivot)
return self
def manhattanize_fast(self, grid_x: numpy.ndarray, grid_y: numpy.ndarray) -> List['Polygon']:
def manhattanize_fast(self,
grid_x: numpy.ndarray,
grid_y: numpy.ndarray,
) -> List['Polygon']:
"""
Returns a list of polygons with grid-aligned ("Manhattan") edges approximating the shape.
@ -295,7 +298,10 @@ class Shape(metaclass=ABCMeta):
return manhattan_polygons
def manhattanize(self, grid_x: numpy.ndarray, grid_y: numpy.ndarray) -> List['Polygon']:
def manhattanize(self,
grid_x: numpy.ndarray,
grid_y: numpy.ndarray
) -> List['Polygon']:
"""
Returns a list of polygons with grid-aligned ("Manhattan") edges approximating the shape.

@ -73,11 +73,11 @@ class Text(Shape):
string: str,
height: float,
font_path: str,
offset: vector2=(0.0, 0.0),
rotation: float=0.0,
mirrored: Tuple[bool]=(False, False),
layer: int=0,
dose: float=1.0):
offset: vector2 = (0.0, 0.0),
rotation: float = 0.0,
mirrored: Tuple[bool] = (False, False),
layer: int = 0,
dose: float = 1.0):
self.offset = offset
self.layer = layer
self.dose = dose
@ -95,8 +95,8 @@ class Text(Shape):
return new
def to_polygons(self,
_poly_num_points: int=None,
_poly_max_arclen: float=None
_poly_num_points: int = None,
_poly_max_arclen: float = None,
) -> List[Polygon]:
all_polygons = []
total_advance = 0
@ -153,7 +153,7 @@ class Text(Shape):
def get_char_as_polygons(font_path: str,
char: str,
resolution: float=48*64,
resolution: float = 48*64,
) -> Tuple[List[List[List[float]]], float]:
from freetype import Face
from matplotlib.path import Path

@ -32,11 +32,11 @@ class SubPattern:
def __init__(self,
pattern: 'Pattern',
offset: vector2=(0.0, 0.0),
rotation: float=0.0,
mirrored: List[bool]=None,
dose: float=1.0,
scale: float=1.0):
offset: vector2 = (0.0, 0.0),
rotation: float = 0.0,
mirrored: List[bool] = None,
dose: float = 1.0,
scale: float = 1.0):
self.identifier = ()
self.pattern = pattern
self.offset = offset

Loading…
Cancel
Save