diff --git a/masque/shapes/arc.py b/masque/shapes/arc.py index 6f948cb..4befb6d 100644 --- a/masque/shapes/arc.py +++ b/masque/shapes/arc.py @@ -422,7 +422,7 @@ class Arc(PositionableImpl, Shape): rotation %= 2 * pi width = self.width - return ((type(self), radii, norm_angles, width / norm_value), + return ((type(self), tuple(radii.tolist()), norm_angles, width / norm_value), (self.offset, scale / norm_value, rotation, False), lambda: Arc( radii=radii * norm_value, diff --git a/masque/shapes/ellipse.py b/masque/shapes/ellipse.py index 8e3fd49..985d252 100644 --- a/masque/shapes/ellipse.py +++ b/masque/shapes/ellipse.py @@ -206,7 +206,7 @@ class Ellipse(PositionableImpl, Shape): radii = self.radii[::-1] / self.radius_y scale = self.radius_y angle = (self.rotation + pi / 2) % pi - return ((type(self), radii), + return ((type(self), tuple(radii.tolist())), (self.offset, scale / norm_value, angle, False), lambda: Ellipse(radii=radii * norm_value)) diff --git a/masque/test/test_library.py b/masque/test/test_library.py index 09c258b..6ac8536 100644 --- a/masque/test/test_library.py +++ b/masque/test/test_library.py @@ -282,6 +282,28 @@ def test_library_dedup_text_preserves_scale_and_mirror_flag() -> None: assert [cast("Text", shape).height for shape in flat.shapes[(1, 0)]] == [10, 10] +def test_library_dedup_handles_arc_and_ellipse_labels() -> None: + lib = Library() + pat = Pattern() + pat.shapes[(1, 0)] += [ + Arc(radii=(10, 20), angles=(0, 1), width=2, offset=(0, 0)), + Arc(radii=(10, 20), angles=(0, 1), width=2, offset=(50, 0)), + ] + pat.shapes[(2, 0)] += [ + Ellipse(radii=(10, 20), offset=(0, 0)), + Ellipse(radii=(10, 20), offset=(50, 0)), + ] + lib["top"] = pat + + lib.dedup(exclude_types=(), norm_value=1, threshold=2) + + assert len(lib["top"].refs) == 2 + assert lib["top"].shapes[(1, 0)] == [] + assert lib["top"].shapes[(2, 0)] == [] + + flat = lib.flatten("top")["top"] + assert sum(isinstance(shape, Arc) for shape in flat.shapes[(1, 0)]) == 2 + assert sum(isinstance(shape, Ellipse) for shape in flat.shapes[(2, 0)]) == 2 def test_library_dedup_handles_multiple_duplicate_groups() -> None: