diff --git a/masque/label.py b/masque/label.py index 6a2a61f..98a65df 100644 --- a/masque/label.py +++ b/masque/label.py @@ -53,6 +53,22 @@ class Label(PositionableImpl, RepeatableImpl, AnnotatableImpl, Bounded, Pivotabl self.repetition = repetition self.annotations = annotations if annotations is not None else {} + @classmethod + def _from_raw( + cls, + string: str, + *, + offset: NDArray[numpy.float64], + repetition: Repetition | None = None, + annotations: annotations_t | None = None, + ) -> Self: + new = cls.__new__(cls) + new._string = string + new._offset = offset + new._repetition = repetition + new._annotations = annotations if annotations is not None else {} + return new + def __copy__(self) -> Self: return type(self)( string=self.string, diff --git a/masque/ref.py b/masque/ref.py index 268d8d4..1d71432 100644 --- a/masque/ref.py +++ b/masque/ref.py @@ -86,6 +86,26 @@ class Ref( self.repetition = repetition self.annotations = annotations if annotations is not None else {} + @classmethod + def _from_raw( + cls, + *, + offset: NDArray[numpy.float64], + rotation: float, + mirrored: bool, + scale: float, + repetition: Repetition | None, + annotations: annotations_t | None, + ) -> Self: + new = cls.__new__(cls) + new._offset = offset + new._rotation = rotation % (2 * pi) + new._scale = scale + new._mirrored = mirrored + new._repetition = repetition + new._annotations = annotations if annotations is not None else {} + return new + def __copy__(self) -> 'Ref': new = Ref( offset=self.offset.copy(), diff --git a/masque/repetition.py b/masque/repetition.py index 1e12fcd..9e8af26 100644 --- a/masque/repetition.py +++ b/masque/repetition.py @@ -113,6 +113,22 @@ class Grid(Repetition): self.a_count = a_count self.b_count = b_count + @classmethod + def _from_raw( + cls: type[GG], + *, + a_vector: NDArray[numpy.float64], + a_count: int, + b_vector: NDArray[numpy.float64], + b_count: int, + ) -> GG: + new = cls.__new__(cls) + new._a_vector = a_vector + new._b_vector = b_vector + new._a_count = int(a_count) + new._b_count = int(b_count) + return new + @classmethod def aligned( cls: type[GG],