From f0eea0382b5a9c6ec2f6a8ee398f4412003ae63d Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Wed, 1 Apr 2026 19:00:59 -0700 Subject: [PATCH] [Ref] get_bounds_single shoudl ignore repetition --- masque/ref.py | 5 ++++- masque/test/test_ref.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/masque/ref.py b/masque/ref.py index b012365..268d8d4 100644 --- a/masque/ref.py +++ b/masque/ref.py @@ -236,7 +236,10 @@ class Ref( bounds = numpy.vstack((numpy.min(corners, axis=0), numpy.max(corners, axis=0))) * self.scale + [self.offset] return bounds - return self.as_pattern(pattern=pattern).get_bounds(library) + + single_ref = self.deepcopy() + single_ref.repetition = None + return single_ref.as_pattern(pattern=pattern).get_bounds(library) def __repr__(self) -> str: rotation = f' r{numpy.rad2deg(self.rotation):g}' if self.rotation != 0 else '' diff --git a/masque/test/test_ref.py b/masque/test/test_ref.py index d3e9778..de330fa 100644 --- a/masque/test/test_ref.py +++ b/masque/test/test_ref.py @@ -64,6 +64,22 @@ def test_ref_get_bounds() -> None: assert_equal(bounds, [[10, 10], [20, 20]]) +def test_ref_get_bounds_single_ignores_repetition_for_non_manhattan_rotation() -> None: + sub_pat = Pattern() + sub_pat.rect((1, 0), xmin=0, xmax=1, ymin=0, ymax=2) + + rep = Grid(a_vector=(5, 0), b_vector=(0, 7), a_count=3, b_count=2) + ref = Ref(offset=(10, 20), rotation=pi / 4, repetition=rep) + + bounds = ref.get_bounds_single(sub_pat) + repeated_bounds = ref.get_bounds(sub_pat) + + assert bounds is not None + assert repeated_bounds is not None + assert repeated_bounds[1, 0] > bounds[1, 0] + assert repeated_bounds[1, 1] > bounds[1, 1] + + def test_ref_copy() -> None: ref1 = Ref(offset=(1, 2), rotation=0.5, annotations={"a": [1]}) ref2 = ref1.copy()