From e8b5c7dec8ca481e54c69a8f3f02b494f92209d0 Mon Sep 17 00:00:00 2001 From: jan Date: Fri, 7 Apr 2023 15:29:14 -0700 Subject: [PATCH] lshift operator shouldn't special-case trees Instead, just call .tops() if there are multiple cells, and fail if there are multiple tops --- masque/library.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/masque/library.py b/masque/library.py index 5236ae7..4c12125 100644 --- a/masque/library.py +++ b/masque/library.py @@ -586,13 +586,18 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta) return rename_map.get(name, name) def __lshift__(self, other: Mapping[str, 'Pattern']) -> str: - if isinstance(other, Tree): - return self.add_tree(other) # Add library and return topcell name +# if isinstance(other, Tree): +# return self.add_tree(other) # Add library and return topcell name - if len(other) != 1: - raise LibraryError('Received a non-Tree library containing multiple cells') + if len(other) == 1: + name = next(iter(other)) + else: + tops = other.tops() + if len(other.tops()) > 1: + raise LibraryError('Received a library containing multiple topcells!') + + name = tops[0] - name = next(iter(other)) rename_map = self.add(other) return rename_map.get(name, name)