Allow setting subpattern identifier in constructors

This commit is contained in:
Jan Petykiewicz 2020-05-17 14:12:27 -07:00
parent 8302286a7a
commit 8a404a2602
2 changed files with 10 additions and 8 deletions

View File

@ -3,7 +3,7 @@
instances of a Pattern in the same parent Pattern. 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 copy
import numpy import numpy
@ -75,7 +75,7 @@ class GridRepetition:
_b_count: int _b_count: int
""" Number of instances along the direction specified by the `b_vector` """ """ Number of instances along the direction specified by the `b_vector` """
identifier: Tuple identifier: Tuple[Any, ...]
""" Arbitrary identifier """ """ Arbitrary identifier """
locked: bool locked: bool
@ -92,7 +92,8 @@ class GridRepetition:
mirrored: Optional[Sequence[bool]] = None, mirrored: Optional[Sequence[bool]] = None,
dose: float = 1.0, dose: float = 1.0,
scale: float = 1.0, scale: float = 1.0,
locked: bool = False): locked: bool = False,
identifier: Tuple[Any, ...] = ()):
""" """
Args: Args:
a_vector: First lattice vector, of the form `[x, y]`. a_vector: First lattice vector, of the form `[x, y]`.
@ -128,7 +129,7 @@ class GridRepetition:
self.a_count = a_count self.a_count = a_count
self.b_count = b_count self.b_count = b_count
self.identifier = () self.identifier = identifier
self.pattern = pattern self.pattern = pattern
self.offset = offset self.offset = offset
self.rotation = rotation self.rotation = rotation

View File

@ -3,7 +3,7 @@
offset, rotation, scaling, and other such properties to the reference. 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 copy
import numpy import numpy
@ -50,7 +50,7 @@ class SubPattern:
_mirrored: numpy.ndarray # ndarray[bool] _mirrored: numpy.ndarray # ndarray[bool]
""" Whether to mirror the instanc across the x and/or y axes. """ """ Whether to mirror the instanc across the x and/or y axes. """
identifier: Tuple identifier: Tuple[Any, ...]
""" An arbitrary identifier """ """ An arbitrary identifier """
locked: bool locked: bool
@ -65,9 +65,10 @@ class SubPattern:
mirrored: Optional[Sequence[bool]] = None, mirrored: Optional[Sequence[bool]] = None,
dose: float = 1.0, dose: float = 1.0,
scale: float = 1.0, scale: float = 1.0,
locked: bool = False): locked: bool = False,
identifier: Tuple[Any, ...] = ()):
object.__setattr__(self, 'locked', False) object.__setattr__(self, 'locked', False)
self.identifier = () self.identifier = identifier
self.pattern = pattern self.pattern = pattern
self.offset = offset self.offset = offset
self.rotation = rotation self.rotation = rotation