[PortsLibraryView] now accepts overrides

This commit is contained in:
Jan Petykiewicz 2026-07-09 19:47:26 -07:00
commit 7083edc7ca
4 changed files with 160 additions and 12 deletions

View file

@ -42,11 +42,12 @@ from ...library import (
from ...utils import apply_transforms
if TYPE_CHECKING:
from collections.abc import Iterator, Sequence
from collections.abc import Iterator, Mapping, Sequence
from numpy.typing import NDArray
from ...pattern import Pattern
from ...ports import Port
logger = logging.getLogger(__name__)
@ -284,12 +285,28 @@ class GdsLibrarySource(ILibraryView):
layers: Sequence[tuple[int, int] | int],
max_depth: int = 0,
skip_subcells: bool = True,
ports: Mapping[str, Mapping[str, Port]] | None = None,
replace: bool = False,
) -> PortsLibraryView:
return PortsLibraryView(
self,
layers=layers,
max_depth=max_depth,
skip_subcells=skip_subcells,
ports=ports,
replace=replace,
)
def with_port_overrides(
self,
ports: Mapping[str, Mapping[str, Port]],
*,
replace: bool = False,
) -> PortsLibraryView:
return PortsLibraryView(
self,
ports=ports,
replace=replace,
)
def find_refs_local(

View file

@ -28,12 +28,13 @@ from ...library import (
from ...utils import apply_transforms
if TYPE_CHECKING:
from collections.abc import Iterator, Sequence
from collections.abc import Iterator, Mapping, Sequence
from numpy.typing import NDArray
import pyarrow
from ...pattern import Pattern
from ...ports import Port
logger = logging.getLogger(__name__)
@ -407,12 +408,28 @@ class ArrowLibrary(ILibraryView):
layers: Sequence[tuple[int, int] | int],
max_depth: int = 0,
skip_subcells: bool = True,
ports: Mapping[str, Mapping[str, Port]] | None = None,
replace: bool = False,
) -> PortsLibraryView:
return PortsLibraryView(
self,
layers=layers,
max_depth=max_depth,
skip_subcells=skip_subcells,
ports=ports,
replace=replace,
)
def with_port_overrides(
self,
ports: Mapping[str, Mapping[str, Port]],
*,
replace: bool = False,
) -> PortsLibraryView:
return PortsLibraryView(
self,
ports=ports,
replace=replace,
)
def close(self) -> None: