various fixes and cleanup
mainly involving ports_to_data and data_to_ports
This commit is contained in:
parent
16567c8a66
commit
963918d1d9
13 changed files with 62 additions and 54 deletions
|
|
@ -27,12 +27,13 @@
|
|||
|
||||
"""
|
||||
|
||||
from .utils import layer_t, annotations_t, SupportsBool
|
||||
from .error import MasqueError, PatternError, LibraryError, BuildError
|
||||
from .shapes import Shape, Polygon, Path, Circle, Arc, Ellipse
|
||||
from .label import Label
|
||||
from .ref import Ref
|
||||
from .pattern import Pattern
|
||||
from .utils import layer_t, annotations_t
|
||||
|
||||
from .library import Library, MutableLibrary, WrapROLibrary, WrapLibrary, LazyLibrary, AbstractView
|
||||
from .ports import Port, PortList
|
||||
from .abstract import Abstract
|
||||
|
|
|
|||
|
|
@ -10,16 +10,16 @@ from abc import ABCMeta, abstractmethod
|
|||
import numpy
|
||||
from numpy.typing import ArrayLike, NDArray
|
||||
|
||||
from .error import PatternError
|
||||
from .utils import rotation_matrix_2d, AutoSlots
|
||||
from .traits import Copyable, Scalable, Rotatable, Mirrorable
|
||||
from .error import PatternError
|
||||
from .utils import rotation_matrix_2d
|
||||
|
||||
|
||||
class Repetition(Copyable, Rotatable, Mirrorable, Scalable, metaclass=ABCMeta):
|
||||
"""
|
||||
Interface common to all objects which specify repetitions
|
||||
"""
|
||||
__slots__ = ()
|
||||
__slots__ = () # Allow subclasses to use __slots__
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
|
|
@ -30,7 +30,7 @@ class Repetition(Copyable, Rotatable, Mirrorable, Scalable, metaclass=ABCMeta):
|
|||
pass
|
||||
|
||||
|
||||
class Grid(Repetition, metaclass=AutoSlots):
|
||||
class Grid(Repetition):
|
||||
"""
|
||||
`Grid` describes a 2D grid formed by two basis vectors and two 'counts' (sizes).
|
||||
|
||||
|
|
@ -279,7 +279,7 @@ class Grid(Repetition, metaclass=AutoSlots):
|
|||
return True
|
||||
|
||||
|
||||
class Arbitrary(Repetition, metaclass=AutoSlots):
|
||||
class Arbitrary(Repetition):
|
||||
"""
|
||||
`Arbitrary` is a simple list of (absolute) displacements for instances.
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ from numpy import pi
|
|||
from numpy.typing import NDArray, ArrayLike
|
||||
|
||||
from . import Shape, Polygon, normalized_shape_tuple, DEFAULT_POLY_NUM_POINTS
|
||||
from .. import PatternError
|
||||
from ..error import PatternError
|
||||
from ..repetition import Repetition
|
||||
from ..utils import is_scalar, layer_t, AutoSlots, annotations_t
|
||||
from ..utils import is_scalar, layer_t, annotations_t
|
||||
|
||||
|
||||
class Arc(Shape, metaclass=AutoSlots):
|
||||
class Arc(Shape):
|
||||
"""
|
||||
An elliptical arc, formed by cutting off an elliptical ring with two rays which exit from its
|
||||
center. It has a position, two radii, a start and stop angle, a rotation, and a width.
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ from numpy import pi
|
|||
from numpy.typing import NDArray, ArrayLike
|
||||
|
||||
from . import Shape, Polygon, normalized_shape_tuple, DEFAULT_POLY_NUM_POINTS
|
||||
from .. import PatternError
|
||||
from ..error import PatternError
|
||||
from ..repetition import Repetition
|
||||
from ..utils import is_scalar, layer_t, AutoSlots, annotations_t
|
||||
from ..utils import is_scalar, layer_t, annotations_t
|
||||
|
||||
|
||||
class Circle(Shape, metaclass=AutoSlots):
|
||||
class Circle(Shape):
|
||||
"""
|
||||
A circle, which has a position and radius.
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ from numpy import pi
|
|||
from numpy.typing import ArrayLike, NDArray
|
||||
|
||||
from . import Shape, Polygon, normalized_shape_tuple, DEFAULT_POLY_NUM_POINTS
|
||||
from .. import PatternError
|
||||
from ..error import PatternError
|
||||
from ..repetition import Repetition
|
||||
from ..utils import is_scalar, rotation_matrix_2d, layer_t, AutoSlots, annotations_t
|
||||
from ..utils import is_scalar, rotation_matrix_2d, layer_t, annotations_t
|
||||
|
||||
|
||||
class Ellipse(Shape, metaclass=AutoSlots):
|
||||
class Ellipse(Shape):
|
||||
"""
|
||||
An ellipse, which has a position, two radii, and a rotation.
|
||||
The rotation gives the angle from x-axis, counterclockwise, to the first (x) radius.
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ from numpy import pi, inf
|
|||
from numpy.typing import NDArray, ArrayLike
|
||||
|
||||
from . import Shape, normalized_shape_tuple, Polygon, Circle
|
||||
from .. import PatternError
|
||||
from ..error import PatternError
|
||||
from ..repetition import Repetition
|
||||
from ..utils import is_scalar, rotation_matrix_2d, layer_t, AutoSlots
|
||||
from ..utils import is_scalar, rotation_matrix_2d, layer_t
|
||||
from ..utils import remove_colinear_vertices, remove_duplicate_vertices, annotations_t
|
||||
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ class PathCap(Enum):
|
|||
# # defined by path.cap_extensions
|
||||
|
||||
|
||||
class Path(Shape, metaclass=AutoSlots):
|
||||
class Path(Shape):
|
||||
"""
|
||||
A path, consisting of a bunch of vertices (Nx2 ndarray), a width, an end-cap shape,
|
||||
and an offset.
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ from numpy import pi
|
|||
from numpy.typing import NDArray, ArrayLike
|
||||
|
||||
from . import Shape, normalized_shape_tuple
|
||||
from .. import PatternError
|
||||
from ..error import PatternError
|
||||
from ..repetition import Repetition
|
||||
from ..utils import is_scalar, rotation_matrix_2d, layer_t, AutoSlots
|
||||
from ..utils import is_scalar, rotation_matrix_2d, layer_t
|
||||
from ..utils import remove_colinear_vertices, remove_duplicate_vertices, annotations_t
|
||||
|
||||
|
||||
class Polygon(Shape, metaclass=AutoSlots):
|
||||
class Polygon(Shape):
|
||||
"""
|
||||
A polygon, consisting of a bunch of vertices (Nx2 ndarray) which specify an
|
||||
implicitly-closed boundary, and an offset.
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ from numpy import pi, inf
|
|||
from numpy.typing import NDArray, ArrayLike
|
||||
|
||||
from . import Shape, Polygon, normalized_shape_tuple
|
||||
from .. import PatternError
|
||||
from ..error import PatternError
|
||||
from ..repetition import Repetition
|
||||
from ..traits import RotatableImpl
|
||||
from ..utils import is_scalar, get_bit, normalize_mirror, layer_t, AutoSlots
|
||||
from ..utils import is_scalar, get_bit, normalize_mirror, layer_t
|
||||
from ..utils import annotations_t
|
||||
|
||||
# Loaded on use:
|
||||
|
|
@ -17,7 +17,7 @@ from ..utils import annotations_t
|
|||
# from matplotlib.path import Path
|
||||
|
||||
|
||||
class Text(RotatableImpl, Shape, metaclass=AutoSlots):
|
||||
class Text(RotatableImpl, Shape):
|
||||
"""
|
||||
Text (to be printed e.g. as a set of polygons).
|
||||
This is distinct from non-printed Label objects.
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Positionable(metaclass=ABCMeta):
|
|||
|
||||
@offset.setter
|
||||
@abstractmethod
|
||||
def offset(self, val: ArrayLike):
|
||||
def offset(self, val: ArrayLike) -> None:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from typing import TypeVar, cast
|
||||
from typing import TypeVar, cast, Any
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
import numpy
|
||||
|
|
@ -114,6 +114,9 @@ class PivotableImpl(Pivotable, metaclass=ABCMeta):
|
|||
"""
|
||||
__slots__ = ()
|
||||
|
||||
offset: Any # TODO see if we can get around defining `offset` in PivotableImpl
|
||||
""" `[x_offset, y_offset]` """
|
||||
|
||||
def rotate_around(self: J, pivot: ArrayLike, rotation: float) -> J:
|
||||
pivot = numpy.array(pivot, dtype=float)
|
||||
cast(Positionable, self).translate(-pivot)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
Various helper functions, type definitions, etc.
|
||||
"""
|
||||
from .types import layer_t, annotations_t, SupportsBool
|
||||
|
||||
from .array import is_scalar
|
||||
from .autoslots import AutoSlots
|
||||
from .deferreddict import DeferredDict
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue