From d48c0f2879a61139eb18b7968245fcf1141e2884 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Mon, 14 Sep 2026 21:55:06 -0700 Subject: [PATCH] [RectCollection] advise the user what to do if they want to make a non-manhattan rotation --- masque/shapes/rect_collection.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/masque/shapes/rect_collection.py b/masque/shapes/rect_collection.py index eaf028f..291f23a 100644 --- a/masque/shapes/rect_collection.py +++ b/masque/shapes/rect_collection.py @@ -187,7 +187,12 @@ class RectCollection(Shape): def rotate(self, theta: float) -> Self: quarter_turns = int(numpy.rint(theta / (pi / 2))) if not numpy.isclose(theta, quarter_turns * (pi / 2)): - raise PatternError('RectCollection only supports Manhattan rotations') + raise PatternError( + f'RectCollection cannot rotate by {theta!r} radians; only Manhattan rotations (multiples of pi/2) are supported. ' + 'Explicitly replace the collection with to_polygons(), or call Pattern.polygonize() ' + 'on the pattern containing it (including referenced child patterns) before transforming, ' + 'flattening, or computing hierarchical bounds.' + ) turns = quarter_turns % 4 if turns == 0 or self._rects.size == 0: return self