Improve type annotations for layer

This commit is contained in:
Jan Petykiewicz 2020-05-11 18:39:02 -07:00
commit df179c9233
10 changed files with 29 additions and 28 deletions

View file

@ -6,10 +6,10 @@ from numpy import pi
from . import Shape, Polygon, normalized_shape_tuple, DEFAULT_POLY_NUM_POINTS
from .. import PatternError
from ..utils import is_scalar, vector2
__author__ = 'Jan Petykiewicz'
from ..utils import is_scalar, vector2, layer_t
class Arc(Shape):
@ -158,7 +158,7 @@ class Arc(Shape):
offset: vector2 = (0.0, 0.0),
rotation: float = 0,
mirrored: Tuple[bool] = (False, False),
layer: int = 0,
layer: layer_t = 0,
dose: float = 1.0,
locked: bool = False):
self.unlock()

View file

@ -5,10 +5,10 @@ from numpy import pi
from . import Shape, Polygon, normalized_shape_tuple, DEFAULT_POLY_NUM_POINTS
from .. import PatternError
from ..utils import is_scalar, vector2
__author__ = 'Jan Petykiewicz'
from ..utils import is_scalar, vector2, layer_t
class Circle(Shape):
@ -46,7 +46,7 @@ class Circle(Shape):
poly_num_points: int = DEFAULT_POLY_NUM_POINTS,
poly_max_arclen: float = None,
offset: vector2 = (0.0, 0.0),
layer: int = 0,
layer: layer_t = 0,
dose: float = 1.0,
locked: bool = False):
self.unlock()

View file

@ -6,10 +6,10 @@ from numpy import pi
from . import Shape, Polygon, normalized_shape_tuple, DEFAULT_POLY_NUM_POINTS
from .. import PatternError
from ..utils import is_scalar, rotation_matrix_2d, vector2
__author__ = 'Jan Petykiewicz'
from ..utils import is_scalar, rotation_matrix_2d, vector2, layer_t
class Ellipse(Shape):
@ -93,7 +93,7 @@ class Ellipse(Shape):
offset: vector2 = (0.0, 0.0),
rotation: float = 0,
mirrored: Tuple[bool] = (False, False),
layer: int = 0,
layer: layer_t = 0,
dose: float = 1.0,
locked: bool = False):
self.unlock()

View file

@ -6,7 +6,7 @@ from numpy import pi, inf
from . import Shape, normalized_shape_tuple, Polygon, Circle
from .. import PatternError
from ..utils import is_scalar, rotation_matrix_2d, vector2
from ..utils import is_scalar, rotation_matrix_2d, vector2, layer_t
from ..utils import remove_colinear_vertices, remove_duplicate_vertices
__author__ = 'Jan Petykiewicz'
@ -144,7 +144,7 @@ class Path(Shape):
offset: vector2 = (0.0, 0.0),
rotation: float = 0,
mirrored: Tuple[bool] = (False, False),
layer: int = 0,
layer: layer_t = 0,
dose: float = 1.0,
locked: bool = False,
) -> 'Path':
@ -182,7 +182,7 @@ class Path(Shape):
offset: vector2 = (0.0, 0.0),
rotation: float = 0,
mirrored: Tuple[bool] = (False, False),
layer: int = 0,
layer: layer_t = 0,
dose: float = 1.0,
) -> 'Path':
"""

View file

@ -5,7 +5,7 @@ from numpy import pi
from . import Shape, normalized_shape_tuple
from .. import PatternError
from ..utils import is_scalar, rotation_matrix_2d, vector2
from ..utils import is_scalar, rotation_matrix_2d, vector2, layer_t
from ..utils import remove_colinear_vertices, remove_duplicate_vertices
__author__ = 'Jan Petykiewicz'
@ -74,7 +74,7 @@ class Polygon(Shape):
offset: vector2 = (0.0, 0.0),
rotation: float = 0.0,
mirrored: Tuple[bool] = (False, False),
layer: int = 0,
layer: layer_t = 0,
dose: float = 1.0,
locked: bool = False,
):
@ -100,7 +100,7 @@ class Polygon(Shape):
def square(side_length: float,
rotation: float = 0.0,
offset: vector2 = (0.0, 0.0),
layer: int = 0,
layer: layer_t = 0,
dose: float = 1.0,
) -> 'Polygon':
"""
@ -130,7 +130,7 @@ class Polygon(Shape):
ly: float,
rotation: float = 0,
offset: vector2 = (0.0, 0.0),
layer: int = 0,
layer: layer_t = 0,
dose: float = 1.0,
) -> 'Polygon':
"""
@ -164,7 +164,7 @@ class Polygon(Shape):
yctr: float = None,
ymax: float = None,
ly: float = None,
layer: int = 0,
layer: layer_t = 0,
dose: float = 1.0,
) -> 'Polygon':
"""

View file

@ -4,7 +4,7 @@ import copy
import numpy
from ..error import PatternError, PatternLockedError
from ..utils import is_scalar, rotation_matrix_2d, vector2
from ..utils import is_scalar, rotation_matrix_2d, vector2, layer_t
__author__ = 'Jan Petykiewicz'
@ -29,7 +29,7 @@ class Shape(metaclass=ABCMeta):
_offset: numpy.ndarray
""" `[x_offset, y_offset]` """
_layer: int or Tuple
_layer: layer_t
""" Layer (integer >= 0 or tuple) """
_dose: float
@ -162,14 +162,14 @@ class Shape(metaclass=ABCMeta):
# layer property
@property
def layer(self) -> int or Tuple[int]:
def layer(self) -> layer_t:
"""
Layer number (int or tuple of ints)
"""
return self._layer
@layer.setter
def layer(self, val: int or List[int]):
def layer(self, val: layer_t):
self._layer = val
# dose property

View file

@ -5,7 +5,7 @@ from numpy import pi, inf
from . import Shape, Polygon, normalized_shape_tuple
from .. import PatternError
from ..utils import is_scalar, vector2, get_bit, normalize_mirror
from ..utils import is_scalar, vector2, get_bit, normalize_mirror, layer_t
# Loaded on use:
# from freetype import Face
@ -76,7 +76,7 @@ class Text(Shape):
offset: vector2 = (0.0, 0.0),
rotation: float = 0.0,
mirrored: Tuple[bool] = (False, False),
layer: int = 0,
layer: layer_t = 0,
dose: float = 1.0,
locked: bool = False,
):