From 8a404a2602adfd09f5211ed9111a6b636f3d39ad Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sun, 17 May 2020 14:12:27 -0700 Subject: [PATCH] Allow setting subpattern identifier in constructors --- masque/repetition.py | 9 +++++---- masque/subpattern.py | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/masque/repetition.py b/masque/repetition.py index 7348f2f..e1297d2 100644 --- a/masque/repetition.py +++ b/masque/repetition.py @@ -3,7 +3,7 @@ instances of a Pattern in the same parent Pattern. """ -from typing import Union, List, Dict, Tuple, Optional, Sequence, TYPE_CHECKING +from typing import Union, List, Dict, Tuple, Optional, Sequence, TYPE_CHECKING, Any import copy import numpy @@ -75,7 +75,7 @@ class GridRepetition: _b_count: int """ Number of instances along the direction specified by the `b_vector` """ - identifier: Tuple + identifier: Tuple[Any, ...] """ Arbitrary identifier """ locked: bool @@ -92,7 +92,8 @@ class GridRepetition: mirrored: Optional[Sequence[bool]] = None, dose: float = 1.0, scale: float = 1.0, - locked: bool = False): + locked: bool = False, + identifier: Tuple[Any, ...] = ()): """ Args: a_vector: First lattice vector, of the form `[x, y]`. @@ -128,7 +129,7 @@ class GridRepetition: self.a_count = a_count self.b_count = b_count - self.identifier = () + self.identifier = identifier self.pattern = pattern self.offset = offset self.rotation = rotation diff --git a/masque/subpattern.py b/masque/subpattern.py index 9ca0dc7..7f4bb87 100644 --- a/masque/subpattern.py +++ b/masque/subpattern.py @@ -3,7 +3,7 @@ offset, rotation, scaling, and other such properties to the reference. """ -from typing import Union, List, Dict, Tuple, Optional, Sequence, TYPE_CHECKING +from typing import Union, List, Dict, Tuple, Optional, Sequence, TYPE_CHECKING, Any import copy import numpy @@ -50,7 +50,7 @@ class SubPattern: _mirrored: numpy.ndarray # ndarray[bool] """ Whether to mirror the instanc across the x and/or y axes. """ - identifier: Tuple + identifier: Tuple[Any, ...] """ An arbitrary identifier """ locked: bool @@ -65,9 +65,10 @@ class SubPattern: mirrored: Optional[Sequence[bool]] = None, dose: float = 1.0, scale: float = 1.0, - locked: bool = False): + locked: bool = False, + identifier: Tuple[Any, ...] = ()): object.__setattr__(self, 'locked', False) - self.identifier = () + self.identifier = identifier self.pattern = pattern self.offset = offset self.rotation = rotation