From d079b448831fcf72a955ed76a6453fba5dd174b5 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Tue, 7 Feb 2023 09:19:01 -0800 Subject: [PATCH] Revert "allow ports2data to take a tree" This reverts commit 44f823c736bd5a8fd696562b6a732361295ff09b. LazyLibrary can't take Trees anymore, so no need for it. --- masque/utils/ports2data.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/masque/utils/ports2data.py b/masque/utils/ports2data.py index b634543..8dba890 100644 --- a/masque/utils/ports2data.py +++ b/masque/utils/ports2data.py @@ -6,7 +6,7 @@ and retrieving it (`data_to_ports`). the port locations. This particular approach is just a sensible default; feel free to to write equivalent functions for your own format or alternate storage methods. """ -from typing import Sequence, Optional, Mapping, Union +from typing import Sequence, Optional, Mapping import logging import numpy @@ -16,13 +16,13 @@ from ..label import Label from ..utils import layer_t from ..ports import Port from ..error import PatternError -from ..library import Library, WrapROLibrary, Tree +from ..library import Library, WrapROLibrary logger = logging.getLogger(__name__) -def ports_to_data(pattern_or_tree: Union[Pattern, Tree], layer: layer_t) -> Union[Pattern, Tree]: +def ports_to_data(pattern: Pattern, layer: layer_t) -> Pattern: """ Place a text label at each port location, specifying the port data in the format 'name:ptype angle_deg' @@ -39,11 +39,6 @@ def ports_to_data(pattern_or_tree: Union[Pattern, Tree], layer: layer_t) -> Unio Returns: `pattern` """ - pattern: Pattern - if isinstance(pattern_or_tree, Tree): - pattern = pattern_or_tree[pattern_or_tree.top] - else: - pattern = pattern_or_tree for name, port in pattern.ports.items(): if port.rotation is None: angle_deg = numpy.inf @@ -52,7 +47,7 @@ def ports_to_data(pattern_or_tree: Union[Pattern, Tree], layer: layer_t) -> Unio pattern.labels += [ Label(string=f'{name}:{port.ptype} {angle_deg:g}', layer=layer, offset=port.offset) ] - return pattern_or_tree + return pattern def data_to_ports(