From 16c6bfc70a0612bc3ca13625e98ed3bb5f9297f1 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Fri, 17 May 2019 00:39:46 -0700 Subject: [PATCH] Cosmetic changes to argument lists --- masque/pattern.py | 30 +++++++++++++++--------------- masque/shapes/arc.py | 17 ++++++++++------- masque/shapes/circle.py | 15 +++++++++------ masque/shapes/ellipse.py | 16 ++++++++-------- masque/shapes/path.py | 14 +++++++------- masque/shapes/polygon.py | 30 +++++++++++++++--------------- masque/shapes/shape.py | 10 ++++++++-- masque/shapes/text.py | 16 ++++++++-------- masque/subpattern.py | 10 +++++----- 9 files changed, 85 insertions(+), 73 deletions(-) diff --git a/masque/pattern.py b/masque/pattern.py index aa6c459..4e9d730 100644 --- a/masque/pattern.py +++ b/masque/pattern.py @@ -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 diff --git a/masque/shapes/arc.py b/masque/shapes/arc.py index b8e8547..6972e3d 100644 --- a/masque/shapes/arc.py +++ b/masque/shapes/arc.py @@ -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: diff --git a/masque/shapes/circle.py b/masque/shapes/circle.py index 97df5c0..247aa78 100644 --- a/masque/shapes/circle.py +++ b/masque/shapes/circle.py @@ -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: diff --git a/masque/shapes/ellipse.py b/masque/shapes/ellipse.py index 7915007..6be05c8 100644 --- a/masque/shapes/ellipse.py +++ b/masque/shapes/ellipse.py @@ -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 diff --git a/masque/shapes/path.py b/masque/shapes/path.py index 8e3b385..6525ec1 100644 --- a/masque/shapes/path.py +++ b/masque/shapes/path.py @@ -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() diff --git a/masque/shapes/polygon.py b/masque/shapes/polygon.py index fda6cd7..503d9a5 100644 --- a/masque/shapes/polygon.py +++ b/masque/shapes/polygon.py @@ -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)] diff --git a/masque/shapes/shape.py b/masque/shapes/shape.py index 4dca5ae..00d9c18 100644 --- a/masque/shapes/shape.py +++ b/masque/shapes/shape.py @@ -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. diff --git a/masque/shapes/text.py b/masque/shapes/text.py index 5824a62..a579e9b 100644 --- a/masque/shapes/text.py +++ b/masque/shapes/text.py @@ -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 diff --git a/masque/subpattern.py b/masque/subpattern.py index 745184b..f76605b 100644 --- a/masque/subpattern.py +++ b/masque/subpattern.py @@ -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