From 78a4416f4ca3d96900292e31ed8ca53ce55c0f8c Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Tue, 15 Jun 2021 16:11:55 -0700 Subject: [PATCH] Fix wrap_repeated_shapes --- masque/pattern.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/masque/pattern.py b/masque/pattern.py index 1a54d48..75173b9 100644 --- a/masque/pattern.py +++ b/masque/pattern.py @@ -605,17 +605,23 @@ class Pattern(LockableImpl, AnnotatableImpl, Mirrorable, metaclass=AutoSlots): if pat is None: return pat + new_shapes = [] for shape in pat.shapes: if shape.repetition is None: + new_shapes.append(shape) continue - pat.addsp(Pattern(name_func(pat, shape), shapes=[shape])) + pat.addsp(Pattern(name_func(pat, shape), shapes=[shape]), repetition=shape.repetition) shape.repetition = None + pat.shapes = new_shapes - for label in self.labels: + new_labels = [] + for label in pat.labels: if label.repetition is None: + new_labels.append(shape) continue - pat.addsp(Pattern(name_func(pat, shape), labels=[label])) + pat.addsp(Pattern(name_func(pat, shape), labels=[label]), repetition=label.repetition) label.repetition = None + pat.labels = new_labels return pat