comment updates
This commit is contained in:
parent
ed77e389af
commit
66f3ad04b7
@ -29,7 +29,7 @@ DEFAULT_POLY_NUM_VERTICES = 24
|
||||
class Shape(PositionableImpl, LayerableImpl, Rotatable, Mirrorable, Copyable, Scalable,
|
||||
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
|
||||
|
||||
@ -40,9 +40,9 @@ class Shape(PositionableImpl, LayerableImpl, Rotatable, Mirrorable, Copyable, Sc
|
||||
object.__setattr__(new, name, getattr(self, name))
|
||||
return new
|
||||
|
||||
'''
|
||||
--- Abstract methods
|
||||
'''
|
||||
#
|
||||
# Methods (abstract)
|
||||
#
|
||||
@abstractmethod
|
||||
def to_polygons(
|
||||
self,
|
||||
@ -88,9 +88,9 @@ class Shape(PositionableImpl, LayerableImpl, Rotatable, Mirrorable, Copyable, Sc
|
||||
"""
|
||||
pass
|
||||
|
||||
'''
|
||||
---- Non-abstract methods
|
||||
'''
|
||||
#
|
||||
# Non-abstract methods
|
||||
#
|
||||
def manhattanize_fast(
|
||||
self,
|
||||
grid_x: ArrayLike,
|
||||
|
@ -10,14 +10,14 @@ _empty_slots = () # Workaround to get mypy to ignore intentionally empty slo
|
||||
|
||||
class Annotatable(metaclass=ABCMeta):
|
||||
"""
|
||||
Abstract class for all annotatable entities
|
||||
Trait class for all annotatable entities
|
||||
Annotations correspond to GDS/OASIS "properties"
|
||||
"""
|
||||
__slots__ = ()
|
||||
|
||||
'''
|
||||
---- Properties
|
||||
'''
|
||||
#
|
||||
# Properties
|
||||
#
|
||||
@property
|
||||
@abstractmethod
|
||||
def annotations(self) -> annotations_t:
|
||||
@ -36,9 +36,9 @@ class AnnotatableImpl(Annotatable, metaclass=ABCMeta):
|
||||
_annotations: annotations_t
|
||||
""" Dictionary storing annotation name/value pairs """
|
||||
|
||||
'''
|
||||
---- Non-abstract properties
|
||||
'''
|
||||
#
|
||||
# Non-abstract properties
|
||||
#
|
||||
@property
|
||||
def annotations(self) -> annotations_t:
|
||||
return self._annotations
|
||||
|
@ -5,13 +5,13 @@ import copy
|
||||
|
||||
class Copyable(metaclass=ABCMeta):
|
||||
"""
|
||||
Abstract class which adds .copy() and .deepcopy()
|
||||
Trait class which adds .copy() and .deepcopy()
|
||||
"""
|
||||
__slots__ = ()
|
||||
|
||||
'''
|
||||
---- Non-abstract methods
|
||||
'''
|
||||
#
|
||||
# Non-abstract methods
|
||||
#
|
||||
def copy(self) -> Self:
|
||||
"""
|
||||
Return a shallow copy of the object.
|
||||
|
@ -9,12 +9,12 @@ _empty_slots = () # Workaround to get mypy to ignore intentionally empty slo
|
||||
|
||||
class Layerable(metaclass=ABCMeta):
|
||||
"""
|
||||
Abstract class for all layerable entities
|
||||
Trait class for all layerable entities
|
||||
"""
|
||||
__slots__ = ()
|
||||
'''
|
||||
---- Properties
|
||||
'''
|
||||
#
|
||||
# Properties
|
||||
#
|
||||
@property
|
||||
@abstractmethod
|
||||
def layer(self) -> layer_t:
|
||||
@ -28,9 +28,9 @@ class Layerable(metaclass=ABCMeta):
|
||||
# def layer(self, val: layer_t):
|
||||
# pass
|
||||
|
||||
'''
|
||||
---- Methods
|
||||
'''
|
||||
#
|
||||
# Methods
|
||||
#
|
||||
@abstractmethod
|
||||
def set_layer(self, layer: layer_t) -> Self:
|
||||
"""
|
||||
@ -54,9 +54,9 @@ class LayerableImpl(Layerable, metaclass=ABCMeta):
|
||||
_layer: layer_t
|
||||
""" Layer number, pair, or name """
|
||||
|
||||
'''
|
||||
---- Non-abstract properties
|
||||
'''
|
||||
#
|
||||
# Non-abstract properties
|
||||
#
|
||||
@property
|
||||
def layer(self) -> layer_t:
|
||||
return self._layer
|
||||
@ -65,9 +65,9 @@ class LayerableImpl(Layerable, metaclass=ABCMeta):
|
||||
def layer(self, val: layer_t):
|
||||
self._layer = val
|
||||
|
||||
'''
|
||||
---- Non-abstract methods
|
||||
'''
|
||||
#
|
||||
# Non-abstract methods
|
||||
#
|
||||
def set_layer(self, layer: layer_t) -> Self:
|
||||
self.layer = layer
|
||||
return self
|
||||
|
@ -4,13 +4,10 @@ from abc import ABCMeta, abstractmethod
|
||||
|
||||
class Mirrorable(metaclass=ABCMeta):
|
||||
"""
|
||||
Abstract class for all mirrorable entities
|
||||
Trait class for all mirrorable entities
|
||||
"""
|
||||
__slots__ = ()
|
||||
|
||||
'''
|
||||
---- Abstract methods
|
||||
'''
|
||||
@abstractmethod
|
||||
def mirror(self, axis: int) -> Self:
|
||||
"""
|
||||
@ -50,9 +47,9 @@ class Mirrorable(metaclass=ABCMeta):
|
||||
# _mirrored: numpy.ndarray # ndarray[bool]
|
||||
# """ Whether to mirror the instance across the x and/or y axes. """
|
||||
#
|
||||
# '''
|
||||
# ---- Properties
|
||||
# '''
|
||||
# #
|
||||
# # Properties
|
||||
# #
|
||||
# # Mirrored property
|
||||
# @property
|
||||
# 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')
|
||||
# self._mirrored = numpy.array(val, dtype=bool, copy=True)
|
||||
#
|
||||
# '''
|
||||
# ---- Methods
|
||||
# '''
|
||||
# #
|
||||
# # Methods
|
||||
# #
|
||||
|
@ -14,13 +14,13 @@ _empty_slots = () # Workaround to get mypy to ignore intentionally empty slo
|
||||
|
||||
class Positionable(metaclass=ABCMeta):
|
||||
"""
|
||||
Abstract class for all positionable entities
|
||||
Trait class for all positionable entities
|
||||
"""
|
||||
__slots__ = ()
|
||||
|
||||
'''
|
||||
---- Abstract properties
|
||||
'''
|
||||
#
|
||||
# Properties
|
||||
#
|
||||
@property
|
||||
@abstractmethod
|
||||
def offset(self) -> NDArray[numpy.float64]:
|
||||
@ -89,9 +89,9 @@ class PositionableImpl(Positionable, metaclass=ABCMeta):
|
||||
_offset: NDArray[numpy.float64]
|
||||
""" `[x_offset, y_offset]` """
|
||||
|
||||
'''
|
||||
---- Properties
|
||||
'''
|
||||
#
|
||||
# Properties
|
||||
#
|
||||
# offset property
|
||||
@property
|
||||
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')
|
||||
self._offset = val.flatten() # type: ignore
|
||||
|
||||
'''
|
||||
---- Methods
|
||||
'''
|
||||
#
|
||||
# Methods
|
||||
#
|
||||
def set_offset(self, offset: ArrayLike) -> Self:
|
||||
self.offset = offset
|
||||
return self
|
||||
|
@ -13,13 +13,13 @@ if TYPE_CHECKING:
|
||||
|
||||
class Repeatable(metaclass=ABCMeta):
|
||||
"""
|
||||
Abstract class for all repeatable entities
|
||||
Trait class for all repeatable entities
|
||||
"""
|
||||
__slots__ = ()
|
||||
|
||||
'''
|
||||
---- Properties
|
||||
'''
|
||||
#
|
||||
# Properties
|
||||
#
|
||||
@property
|
||||
@abstractmethod
|
||||
def repetition(self) -> 'Repetition | None':
|
||||
@ -33,9 +33,9 @@ class Repeatable(metaclass=ABCMeta):
|
||||
# def repetition(self, repetition: 'Repetition | None'):
|
||||
# pass
|
||||
|
||||
'''
|
||||
---- Methods
|
||||
'''
|
||||
#
|
||||
# Methods
|
||||
#
|
||||
@abstractmethod
|
||||
def set_repetition(self, repetition: 'Repetition | None') -> Self:
|
||||
"""
|
||||
@ -59,9 +59,9 @@ class RepeatableImpl(Repeatable, metaclass=ABCMeta):
|
||||
_repetition: 'Repetition | None'
|
||||
""" Repetition object, or None (single instance only) """
|
||||
|
||||
'''
|
||||
---- Non-abstract properties
|
||||
'''
|
||||
#
|
||||
# Non-abstract properties
|
||||
#
|
||||
@property
|
||||
def repetition(self) -> 'Repetition | None':
|
||||
return self._repetition
|
||||
@ -73,9 +73,9 @@ class RepeatableImpl(Repeatable, metaclass=ABCMeta):
|
||||
raise MasqueError(f'{repetition} is not a valid Repetition object!')
|
||||
self._repetition = repetition
|
||||
|
||||
'''
|
||||
---- Non-abstract methods
|
||||
'''
|
||||
#
|
||||
# Non-abstract methods
|
||||
#
|
||||
def set_repetition(self, repetition: 'Repetition | None') -> Self:
|
||||
self.repetition = repetition
|
||||
return self
|
||||
|
@ -15,13 +15,13 @@ _empty_slots = () # Workaround to get mypy to ignore intentionally empty slo
|
||||
|
||||
class Rotatable(metaclass=ABCMeta):
|
||||
"""
|
||||
Abstract class for all rotatable entities
|
||||
Trait class for all rotatable entities
|
||||
"""
|
||||
__slots__ = ()
|
||||
|
||||
'''
|
||||
---- Abstract methods
|
||||
'''
|
||||
#
|
||||
# Methods
|
||||
#
|
||||
@abstractmethod
|
||||
def rotate(self, val: float) -> Self:
|
||||
"""
|
||||
@ -45,9 +45,9 @@ class RotatableImpl(Rotatable, metaclass=ABCMeta):
|
||||
_rotation: float
|
||||
""" rotation for the object, radians counterclockwise """
|
||||
|
||||
'''
|
||||
---- Properties
|
||||
'''
|
||||
#
|
||||
# Properties
|
||||
#
|
||||
@property
|
||||
def rotation(self) -> float:
|
||||
""" Rotation, radians counterclockwise """
|
||||
@ -59,9 +59,9 @@ class RotatableImpl(Rotatable, metaclass=ABCMeta):
|
||||
raise MasqueError('Rotation must be a scalar')
|
||||
self._rotation = val % (2 * pi)
|
||||
|
||||
'''
|
||||
---- Methods
|
||||
'''
|
||||
#
|
||||
# Methods
|
||||
#
|
||||
def rotate(self, rotation: float) -> Self:
|
||||
self.rotation += rotation
|
||||
return self
|
||||
@ -82,7 +82,7 @@ class RotatableImpl(Rotatable, 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.
|
||||
"""
|
||||
__slots__ = ()
|
||||
|
@ -10,13 +10,13 @@ _empty_slots = () # Workaround to get mypy to ignore intentionally empty slo
|
||||
|
||||
class Scalable(metaclass=ABCMeta):
|
||||
"""
|
||||
Abstract class for all scalable entities
|
||||
Trait class for all scalable entities
|
||||
"""
|
||||
__slots__ = ()
|
||||
|
||||
'''
|
||||
---- Abstract methods
|
||||
'''
|
||||
#
|
||||
# Methods
|
||||
#
|
||||
@abstractmethod
|
||||
def scale_by(self, c: float) -> Self:
|
||||
"""
|
||||
@ -40,9 +40,9 @@ class ScalableImpl(Scalable, metaclass=ABCMeta):
|
||||
_scale: float
|
||||
""" scale factor for the entity """
|
||||
|
||||
'''
|
||||
---- Properties
|
||||
'''
|
||||
#
|
||||
# Properties
|
||||
#
|
||||
@property
|
||||
def scale(self) -> float:
|
||||
return self._scale
|
||||
@ -55,9 +55,9 @@ class ScalableImpl(Scalable, metaclass=ABCMeta):
|
||||
raise MasqueError('Scale must be positive')
|
||||
self._scale = val
|
||||
|
||||
'''
|
||||
---- Methods
|
||||
'''
|
||||
#
|
||||
# Methods
|
||||
#
|
||||
def scale_by(self, c: float) -> Self:
|
||||
self.scale *= c
|
||||
return self
|
||||
|
Loading…
Reference in New Issue
Block a user