From cca6b90830d600c0e654649e202071dcb456e00f Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Tue, 7 Feb 2023 14:24:34 -0800 Subject: [PATCH] misc fixes --- masque/builder/flatbuilder.py | 1 + masque/library.py | 9 ++++++--- masque/utils/ports2data.py | 1 - 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/masque/builder/flatbuilder.py b/masque/builder/flatbuilder.py index 8656c74..29e882b 100644 --- a/masque/builder/flatbuilder.py +++ b/masque/builder/flatbuilder.py @@ -345,6 +345,7 @@ class FlatBuilder(PortList): other_copy.mirror2d(mirrored) other_copy.rotate_around(pivot, rotation) other_copy.translate_elements(offset) + other_copy.ports.clear() self.pattern.append(other_copy) return self diff --git a/masque/library.py b/masque/library.py index 12d133a..6179bca 100644 --- a/masque/library.py +++ b/masque/library.py @@ -44,7 +44,7 @@ def _rename_patterns(lib: 'Library', name: str) -> str: return name stem = name.split('$')[0] - return lib.get_name(stem) + return lib.get_name(stem) class Library(Mapping[str, 'Pattern'], metaclass=ABCMeta): @@ -493,7 +493,7 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta) Returns: (name, pattern) tuple """ - from .pattern import Pattern + from .pattern import NamedPattern #name = self.get_name(base_name) npat = NamedPattern(name) self[name] = npat @@ -550,7 +550,7 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta) if internal_conflicts: raise LibraryError('Renamed patterns conflict with un-renamed names in `other`' + pformat(internal_conflicts)) - conflicts = set(self.keys()) & renamed + conflicts = set(self.keys()) & set(rename_map.values()) if conflicts: raise LibraryError('Unresolved duplicate keys encountered in library merge: ' + pformat(conflicts)) @@ -559,6 +559,8 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta) for old_name, new_name in rename_map.items(): temp.rename(old_name, new_name, move_references=True) + for key in temp.keys(): + self._merge(key, temp, key) else: for key in other.keys(): @@ -592,6 +594,7 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta) name = tree.top else: tree.library.rename(tree.top, name, move_references=True) + tree.top = name self.add(tree.library, rename_theirs=rename_theirs) return name diff --git a/masque/utils/ports2data.py b/masque/utils/ports2data.py index 8dba890..52990fc 100644 --- a/masque/utils/ports2data.py +++ b/masque/utils/ports2data.py @@ -83,7 +83,6 @@ def data_to_ports( Returns: The updated `pattern`. Port labels are not removed. """ - print(f'TODO pat2dev {name}') if pattern.ports: logger.warning(f'Pattern {name if name else pattern} already had ports, skipping data_to_ports') return pattern