comment updates

This commit is contained in:
jan 2023-04-07 23:19:55 -07:00
parent c5c31a5f0f
commit bb3caf1ad7
9 changed files with 82 additions and 85 deletions

View File

@ -29,7 +29,7 @@ DEFAULT_POLY_NUM_VERTICES = 24
class Shape(PositionableImpl, LayerableImpl, Rotatable, Mirrorable, Copyable, Scalable, class Shape(PositionableImpl, LayerableImpl, Rotatable, Mirrorable, Copyable, Scalable,
PivotableImpl, RepeatableImpl, AnnotatableImpl, metaclass=ABCMeta): PivotableImpl, RepeatableImpl, AnnotatableImpl, metaclass=ABCMeta):
""" """
Abstract class specifying functions common to all shapes. Class specifying functions common to all shapes.
""" """
__slots__ = () # Children should use AutoSlots __slots__ = () # Children should use AutoSlots
@ -40,9 +40,9 @@ class Shape(PositionableImpl, LayerableImpl, Rotatable, Mirrorable, Copyable, Sc
object.__setattr__(new, name, getattr(self, name)) object.__setattr__(new, name, getattr(self, name))
return new return new
''' #
--- Abstract methods # Methods (abstract)
''' #
@abstractmethod @abstractmethod
def to_polygons( def to_polygons(
self, self,
@ -88,9 +88,9 @@ class Shape(PositionableImpl, LayerableImpl, Rotatable, Mirrorable, Copyable, Sc
""" """
pass pass
''' #
---- Non-abstract methods # Non-abstract methods
''' #
def manhattanize_fast( def manhattanize_fast(
self, self,
grid_x: ArrayLike, grid_x: ArrayLike,

View File

@ -10,14 +10,14 @@ _empty_slots = () # Workaround to get mypy to ignore intentionally empty slo
class Annotatable(metaclass=ABCMeta): class Annotatable(metaclass=ABCMeta):
""" """
Abstract class for all annotatable entities Trait class for all annotatable entities
Annotations correspond to GDS/OASIS "properties" Annotations correspond to GDS/OASIS "properties"
""" """
__slots__ = () __slots__ = ()
''' #
---- Properties # Properties
''' #
@property @property
@abstractmethod @abstractmethod
def annotations(self) -> annotations_t: def annotations(self) -> annotations_t:
@ -36,9 +36,9 @@ class AnnotatableImpl(Annotatable, metaclass=ABCMeta):
_annotations: annotations_t _annotations: annotations_t
""" Dictionary storing annotation name/value pairs """ """ Dictionary storing annotation name/value pairs """
''' #
---- Non-abstract properties # Non-abstract properties
''' #
@property @property
def annotations(self) -> annotations_t: def annotations(self) -> annotations_t:
return self._annotations return self._annotations

View File

@ -5,13 +5,13 @@ import copy
class Copyable(metaclass=ABCMeta): class Copyable(metaclass=ABCMeta):
""" """
Abstract class which adds .copy() and .deepcopy() Trait class which adds .copy() and .deepcopy()
""" """
__slots__ = () __slots__ = ()
''' #
---- Non-abstract methods # Non-abstract methods
''' #
def copy(self) -> Self: def copy(self) -> Self:
""" """
Return a shallow copy of the object. Return a shallow copy of the object.

View File

@ -9,12 +9,12 @@ _empty_slots = () # Workaround to get mypy to ignore intentionally empty slo
class Layerable(metaclass=ABCMeta): class Layerable(metaclass=ABCMeta):
""" """
Abstract class for all layerable entities Trait class for all layerable entities
""" """
__slots__ = () __slots__ = ()
''' #
---- Properties # Properties
''' #
@property @property
@abstractmethod @abstractmethod
def layer(self) -> layer_t: def layer(self) -> layer_t:
@ -28,9 +28,9 @@ class Layerable(metaclass=ABCMeta):
# def layer(self, val: layer_t): # def layer(self, val: layer_t):
# pass # pass
''' #
---- Methods # Methods
''' #
@abstractmethod @abstractmethod
def set_layer(self, layer: layer_t) -> Self: def set_layer(self, layer: layer_t) -> Self:
""" """
@ -54,9 +54,9 @@ class LayerableImpl(Layerable, metaclass=ABCMeta):
_layer: layer_t _layer: layer_t
""" Layer number, pair, or name """ """ Layer number, pair, or name """
''' #
---- Non-abstract properties # Non-abstract properties
''' #
@property @property
def layer(self) -> layer_t: def layer(self) -> layer_t:
return self._layer return self._layer
@ -65,9 +65,9 @@ class LayerableImpl(Layerable, metaclass=ABCMeta):
def layer(self, val: layer_t): def layer(self, val: layer_t):
self._layer = val self._layer = val
''' #
---- Non-abstract methods # Non-abstract methods
''' #
def set_layer(self, layer: layer_t) -> Self: def set_layer(self, layer: layer_t) -> Self:
self.layer = layer self.layer = layer
return self return self

View File

@ -4,13 +4,10 @@ from abc import ABCMeta, abstractmethod
class Mirrorable(metaclass=ABCMeta): class Mirrorable(metaclass=ABCMeta):
""" """
Abstract class for all mirrorable entities Trait class for all mirrorable entities
""" """
__slots__ = () __slots__ = ()
'''
---- Abstract methods
'''
@abstractmethod @abstractmethod
def mirror(self, axis: int) -> Self: def mirror(self, axis: int) -> Self:
""" """
@ -50,9 +47,9 @@ class Mirrorable(metaclass=ABCMeta):
# _mirrored: numpy.ndarray # ndarray[bool] # _mirrored: numpy.ndarray # ndarray[bool]
# """ Whether to mirror the instance across the x and/or y axes. """ # """ Whether to mirror the instance across the x and/or y axes. """
# #
# ''' # #
# ---- Properties # # Properties
# ''' # #
# # Mirrored property # # Mirrored property
# @property # @property
# def mirrored(self) -> numpy.ndarray: # ndarray[bool] # def mirrored(self) -> numpy.ndarray: # ndarray[bool]
@ -65,6 +62,6 @@ class Mirrorable(metaclass=ABCMeta):
# raise MasqueError('Mirrored must be a 2-element list of booleans') # raise MasqueError('Mirrored must be a 2-element list of booleans')
# self._mirrored = numpy.array(val, dtype=bool, copy=True) # self._mirrored = numpy.array(val, dtype=bool, copy=True)
# #
# ''' # #
# ---- Methods # # Methods
# ''' # #

View File

@ -14,13 +14,13 @@ _empty_slots = () # Workaround to get mypy to ignore intentionally empty slo
class Positionable(metaclass=ABCMeta): class Positionable(metaclass=ABCMeta):
""" """
Abstract class for all positionable entities Trait class for all positionable entities
""" """
__slots__ = () __slots__ = ()
''' #
---- Abstract properties # Properties
''' #
@property @property
@abstractmethod @abstractmethod
def offset(self) -> NDArray[numpy.float64]: def offset(self) -> NDArray[numpy.float64]:
@ -89,9 +89,9 @@ class PositionableImpl(Positionable, metaclass=ABCMeta):
_offset: NDArray[numpy.float64] _offset: NDArray[numpy.float64]
""" `[x_offset, y_offset]` """ """ `[x_offset, y_offset]` """
''' #
---- Properties # Properties
''' #
# offset property # offset property
@property @property
def offset(self) -> Any: # TODO mypy#3003 NDArray[numpy.float64]: def offset(self) -> Any: # TODO mypy#3003 NDArray[numpy.float64]:
@ -109,9 +109,9 @@ class PositionableImpl(Positionable, metaclass=ABCMeta):
raise MasqueError('Offset must be convertible to size-2 ndarray') raise MasqueError('Offset must be convertible to size-2 ndarray')
self._offset = val.flatten() # type: ignore self._offset = val.flatten() # type: ignore
''' #
---- Methods # Methods
''' #
def set_offset(self, offset: ArrayLike) -> Self: def set_offset(self, offset: ArrayLike) -> Self:
self.offset = offset self.offset = offset
return self return self

View File

@ -13,13 +13,13 @@ if TYPE_CHECKING:
class Repeatable(metaclass=ABCMeta): class Repeatable(metaclass=ABCMeta):
""" """
Abstract class for all repeatable entities Trait class for all repeatable entities
""" """
__slots__ = () __slots__ = ()
''' #
---- Properties # Properties
''' #
@property @property
@abstractmethod @abstractmethod
def repetition(self) -> 'Repetition | None': def repetition(self) -> 'Repetition | None':
@ -33,9 +33,9 @@ class Repeatable(metaclass=ABCMeta):
# def repetition(self, repetition: 'Repetition | None'): # def repetition(self, repetition: 'Repetition | None'):
# pass # pass
''' #
---- Methods # Methods
''' #
@abstractmethod @abstractmethod
def set_repetition(self, repetition: 'Repetition | None') -> Self: def set_repetition(self, repetition: 'Repetition | None') -> Self:
""" """
@ -59,9 +59,9 @@ class RepeatableImpl(Repeatable, metaclass=ABCMeta):
_repetition: 'Repetition | None' _repetition: 'Repetition | None'
""" Repetition object, or None (single instance only) """ """ Repetition object, or None (single instance only) """
''' #
---- Non-abstract properties # Non-abstract properties
''' #
@property @property
def repetition(self) -> 'Repetition | None': def repetition(self) -> 'Repetition | None':
return self._repetition return self._repetition
@ -73,9 +73,9 @@ class RepeatableImpl(Repeatable, metaclass=ABCMeta):
raise MasqueError(f'{repetition} is not a valid Repetition object!') raise MasqueError(f'{repetition} is not a valid Repetition object!')
self._repetition = repetition self._repetition = repetition
''' #
---- Non-abstract methods # Non-abstract methods
''' #
def set_repetition(self, repetition: 'Repetition | None') -> Self: def set_repetition(self, repetition: 'Repetition | None') -> Self:
self.repetition = repetition self.repetition = repetition
return self return self

View File

@ -15,13 +15,13 @@ _empty_slots = () # Workaround to get mypy to ignore intentionally empty slo
class Rotatable(metaclass=ABCMeta): class Rotatable(metaclass=ABCMeta):
""" """
Abstract class for all rotatable entities Trait class for all rotatable entities
""" """
__slots__ = () __slots__ = ()
''' #
---- Abstract methods # Methods
''' #
@abstractmethod @abstractmethod
def rotate(self, val: float) -> Self: def rotate(self, val: float) -> Self:
""" """
@ -45,9 +45,9 @@ class RotatableImpl(Rotatable, metaclass=ABCMeta):
_rotation: float _rotation: float
""" rotation for the object, radians counterclockwise """ """ rotation for the object, radians counterclockwise """
''' #
---- Properties # Properties
''' #
@property @property
def rotation(self) -> float: def rotation(self) -> float:
""" Rotation, radians counterclockwise """ """ Rotation, radians counterclockwise """
@ -59,9 +59,9 @@ class RotatableImpl(Rotatable, metaclass=ABCMeta):
raise MasqueError('Rotation must be a scalar') raise MasqueError('Rotation must be a scalar')
self._rotation = val % (2 * pi) self._rotation = val % (2 * pi)
''' #
---- Methods # Methods
''' #
def rotate(self, rotation: float) -> Self: def rotate(self, rotation: float) -> Self:
self.rotation += rotation self.rotation += rotation
return self return self
@ -82,7 +82,7 @@ class RotatableImpl(Rotatable, metaclass=ABCMeta):
class Pivotable(metaclass=ABCMeta): class Pivotable(metaclass=ABCMeta):
""" """
Abstract class for entites which can be rotated around a point. Trait class for entites which can be rotated around a point.
This requires that they are `Positionable` but not necessarily `Rotatable` themselves. This requires that they are `Positionable` but not necessarily `Rotatable` themselves.
""" """
__slots__ = () __slots__ = ()

View File

@ -10,13 +10,13 @@ _empty_slots = () # Workaround to get mypy to ignore intentionally empty slo
class Scalable(metaclass=ABCMeta): class Scalable(metaclass=ABCMeta):
""" """
Abstract class for all scalable entities Trait class for all scalable entities
""" """
__slots__ = () __slots__ = ()
''' #
---- Abstract methods # Methods
''' #
@abstractmethod @abstractmethod
def scale_by(self, c: float) -> Self: def scale_by(self, c: float) -> Self:
""" """
@ -40,9 +40,9 @@ class ScalableImpl(Scalable, metaclass=ABCMeta):
_scale: float _scale: float
""" scale factor for the entity """ """ scale factor for the entity """
''' #
---- Properties # Properties
''' #
@property @property
def scale(self) -> float: def scale(self) -> float:
return self._scale return self._scale
@ -55,9 +55,9 @@ class ScalableImpl(Scalable, metaclass=ABCMeta):
raise MasqueError('Scale must be positive') raise MasqueError('Scale must be positive')
self._scale = val self._scale = val
''' #
---- Methods # Methods
''' #
def scale_by(self, c: float) -> Self: def scale_by(self, c: float) -> Self:
self.scale *= c self.scale *= c
return self return self