From bb3caf1ad74f770d8c03ff6b2f3336ba58c5eb9b Mon Sep 17 00:00:00 2001 From: jan Date: Fri, 7 Apr 2023 23:19:55 -0700 Subject: [PATCH] comment updates --- masque/shapes/shape.py | 14 +++++++------- masque/traits/annotatable.py | 14 +++++++------- masque/traits/copyable.py | 8 ++++---- masque/traits/layerable.py | 26 +++++++++++++------------- masque/traits/mirrorable.py | 17 +++++++---------- masque/traits/positionable.py | 20 ++++++++++---------- masque/traits/repeatable.py | 26 +++++++++++++------------- masque/traits/rotatable.py | 22 +++++++++++----------- masque/traits/scalable.py | 20 ++++++++++---------- 9 files changed, 82 insertions(+), 85 deletions(-) diff --git a/masque/shapes/shape.py b/masque/shapes/shape.py index b88a17b..0699caf 100644 --- a/masque/shapes/shape.py +++ b/masque/shapes/shape.py @@ -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, diff --git a/masque/traits/annotatable.py b/masque/traits/annotatable.py index 0060238..1b2ba23 100644 --- a/masque/traits/annotatable.py +++ b/masque/traits/annotatable.py @@ -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 diff --git a/masque/traits/copyable.py b/masque/traits/copyable.py index 76cd26d..91af84b 100644 --- a/masque/traits/copyable.py +++ b/masque/traits/copyable.py @@ -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. diff --git a/masque/traits/layerable.py b/masque/traits/layerable.py index 29d9653..ec62096 100644 --- a/masque/traits/layerable.py +++ b/masque/traits/layerable.py @@ -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 diff --git a/masque/traits/mirrorable.py b/masque/traits/mirrorable.py index 5bbbad4..2d02f09 100644 --- a/masque/traits/mirrorable.py +++ b/masque/traits/mirrorable.py @@ -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 +# # diff --git a/masque/traits/positionable.py b/masque/traits/positionable.py index ba25cc0..9067cbb 100644 --- a/masque/traits/positionable.py +++ b/masque/traits/positionable.py @@ -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 diff --git a/masque/traits/repeatable.py b/masque/traits/repeatable.py index 492e270..ef22b63 100644 --- a/masque/traits/repeatable.py +++ b/masque/traits/repeatable.py @@ -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 diff --git a/masque/traits/rotatable.py b/masque/traits/rotatable.py index 0e06527..ce89cec 100644 --- a/masque/traits/rotatable.py +++ b/masque/traits/rotatable.py @@ -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__ = () diff --git a/masque/traits/scalable.py b/masque/traits/scalable.py index 2869aef..a3d21e2 100644 --- a/masque/traits/scalable.py +++ b/masque/traits/scalable.py @@ -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