get rid of Mapping stuff on PortsList

This commit is contained in:
Jan Petykiewicz 2023-01-23 22:58:55 -08:00
parent c0b9b7fe81
commit 95c41d4519
2 changed files with 7 additions and 10 deletions

View File

@ -83,6 +83,9 @@ def ell(
if not ports: if not ports:
raise BuildError('Empty port list passed to `ell()`') raise BuildError('Empty port list passed to `ell()`')
if isinstance(ports, PortList):
ports = PortList.ports
if ccw is None: if ccw is None:
if spacing is not None and not numpy.isclose(spacing, 0): if spacing is not None and not numpy.isclose(spacing, 0):
raise BuildError('Spacing must be 0 or None when ccw=None') raise BuildError('Spacing must be 0 or None when ccw=None')

View File

@ -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 from typing import overload, Union, Optional, TypeVar
import warnings import warnings
import traceback import traceback
@ -132,15 +132,9 @@ class PortList(metaclass=ABCMeta):
else: else:
return {k: self.ports[k] for k in key} return {k: self.ports[k] for k in key}
# TODO add Mapping stuff to PortsList # NOTE: Didn't add keys(), items(), values(), __contains__(), etc.
def keys(self) -> KeysView[str]: # because it's weird on stuff like Pattern that contains other lists
return self.ports.keys() # and because you can just grab .ports and use that instead
def values(self) -> ValuesView[Port]:
return self.ports.values()
def items(self) -> ItemsView[str, Port]:
return self.ports.items()
def rename_ports( def rename_ports(
self: PL, self: PL,