lshift operator shouldn't special-case trees

Instead, just call .tops() if there are multiple cells, and fail if
there are multiple tops
This commit is contained in:
jan 2023-04-07 15:29:14 -07:00
parent 0efd9afd16
commit d7e89ef5c8

View File

@ -586,13 +586,18 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta)
return rename_map.get(name, name) return rename_map.get(name, name)
def __lshift__(self, other: Mapping[str, 'Pattern']) -> str: def __lshift__(self, other: Mapping[str, 'Pattern']) -> str:
if isinstance(other, Tree): # if isinstance(other, Tree):
return self.add_tree(other) # Add library and return topcell name # 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)) name = next(iter(other))
else:
tops = other.tops()
if len(other.tops()) > 1:
raise LibraryError('Received a library containing multiple topcells!')
name = tops[0]
rename_map = self.add(other) rename_map = self.add(other)
return rename_map.get(name, name) return rename_map.get(name, name)