From e812c69bfba7d1a91289be9ca30e79b1af063005 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Mon, 23 Jan 2023 22:58:55 -0800 Subject: [PATCH] get rid of Mapping stuff on PortsList --- masque/builder/utils.py | 3 +++ masque/ports.py | 14 ++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/masque/builder/utils.py b/masque/builder/utils.py index 73c5c76..949782a 100644 --- a/masque/builder/utils.py +++ b/masque/builder/utils.py @@ -83,6 +83,9 @@ def ell( if not ports: raise BuildError('Empty port list passed to `ell()`') + if isinstance(ports, PortList): + ports = PortList.ports + if ccw is None: if spacing is not None and not numpy.isclose(spacing, 0): raise BuildError('Spacing must be 0 or None when ccw=None') diff --git a/masque/ports.py b/masque/ports.py index a3716be..a981457 100644 --- a/masque/ports.py +++ b/masque/ports.py @@ -1,4 +1,4 @@ -from typing import Dict, Iterable, List, Tuple, KeysView, ValuesView, ItemsView +from typing import Dict, Iterable, List, Tuple, KeysView, ValuesView from typing import overload, Union, Optional, TypeVar import warnings import traceback @@ -132,15 +132,9 @@ class PortList(metaclass=ABCMeta): else: return {k: self.ports[k] for k in key} - # TODO add Mapping stuff to PortsList - def keys(self) -> KeysView[str]: - return self.ports.keys() - - def values(self) -> ValuesView[Port]: - return self.ports.values() - - def items(self) -> ItemsView[str, Port]: - return self.ports.items() + # NOTE: Didn't add keys(), items(), values(), __contains__(), etc. + # because it's weird on stuff like Pattern that contains other lists + # and because you can just grab .ports and use that instead def rename_ports( self: PL,