add subpattern_t type (generalizattion of SubPattern and GridRepetition)
This commit is contained in:
parent
6b09fc0c20
commit
ee8f015172
@ -31,7 +31,7 @@ import pathlib
|
||||
from .error import PatternError, PatternLockedError
|
||||
from .shapes import Shape
|
||||
from .label import Label
|
||||
from .subpattern import SubPattern
|
||||
from .subpattern import SubPattern, subpattern_t
|
||||
from .repetition import GridRepetition
|
||||
from .pattern import Pattern
|
||||
|
||||
|
@ -18,7 +18,7 @@ import pathlib
|
||||
import gzip
|
||||
|
||||
from .utils import mangle_name, make_dose_table
|
||||
from .. import Pattern, SubPattern, GridRepetition, PatternError, Label, Shape
|
||||
from .. import Pattern, SubPattern, GridRepetition, PatternError, Label, Shape, subpattern_t
|
||||
from ..shapes import Polygon, Path
|
||||
from ..utils import rotation_matrix_2d, get_bit, set_bit, vector2, is_scalar, layer_t
|
||||
from ..utils import remove_colinear_vertices, normalize_mirror
|
||||
@ -467,7 +467,7 @@ def _aref_to_gridrep(element: gdsii.elements.ARef) -> GridRepetition:
|
||||
return gridrep
|
||||
|
||||
|
||||
def _subpatterns_to_refs(subpatterns: List[Union[SubPattern, GridRepetition]]
|
||||
def _subpatterns_to_refs(subpatterns: List[subpattern_t]
|
||||
) -> List[Union[gdsii.elements.ARef, gdsii.elements.SRef]]:
|
||||
refs = []
|
||||
for subpat in subpatterns:
|
||||
|
@ -13,7 +13,7 @@ import numpy
|
||||
from numpy import inf
|
||||
# .visualize imports matplotlib and matplotlib.collections
|
||||
|
||||
from .subpattern import SubPattern
|
||||
from .subpattern import SubPattern, subpattern_t
|
||||
from .repetition import GridRepetition
|
||||
from .shapes import Shape, Polygon
|
||||
from .label import Label
|
||||
@ -40,7 +40,7 @@ class Pattern:
|
||||
labels: List[Label]
|
||||
""" List of all labels in this Pattern. """
|
||||
|
||||
subpatterns: List[Union[SubPattern, GridRepetition]]
|
||||
subpatterns: List[subpattern_t]
|
||||
""" List of all objects referencing other patterns in this Pattern.
|
||||
Examples are SubPattern (gdsii "instances") or GridRepetition (gdsii "arrays")
|
||||
Multiple objects in this list may reference the same Pattern object
|
||||
@ -57,7 +57,7 @@ class Pattern:
|
||||
name: str = '',
|
||||
shapes: Sequence[Shape] = (),
|
||||
labels: Sequence[Label] = (),
|
||||
subpatterns: Sequence[Union[SubPattern, GridRepetition]] = (),
|
||||
subpatterns: Sequence[subpattern_t] = (),
|
||||
locked: bool = False,
|
||||
):
|
||||
"""
|
||||
@ -130,7 +130,7 @@ class Pattern:
|
||||
def subset(self,
|
||||
shapes_func: Callable[[Shape], bool] = None,
|
||||
labels_func: Callable[[Label], bool] = None,
|
||||
subpatterns_func: Callable[[Union[SubPattern, GridRepetition]], bool] = None,
|
||||
subpatterns_func: Callable[[subpattern_t], bool] = None,
|
||||
recursive: bool = False,
|
||||
) -> 'Pattern':
|
||||
"""
|
||||
|
@ -11,6 +11,8 @@ from numpy import pi
|
||||
|
||||
from .error import PatternError, PatternLockedError
|
||||
from .utils import is_scalar, rotation_matrix_2d, vector2
|
||||
from .repetition import GridRepetition
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import Pattern
|
||||
@ -348,3 +350,6 @@ class SubPattern:
|
||||
dose = f' d{self.dose:g}' if self.dose != 1 else ''
|
||||
locked = ' L' if self.locked else ''
|
||||
return f'<SubPattern "{name}" at {self.offset}{rotation}{scale}{mirrored}{dose}{locked}>'
|
||||
|
||||
|
||||
subpattern_t = Union[SubPattern, GridRepetition]
|
||||
|
Loading…
Reference in New Issue
Block a user