[Port] add custom __deepcopy__

This commit is contained in:
Jan Petykiewicz 2026-02-15 00:57:47 -08:00
commit 2b7ad00204

View file

@ -2,6 +2,7 @@ from typing import overload, Self, NoReturn, Any
from collections.abc import Iterable, KeysView, ValuesView, Mapping from collections.abc import Iterable, KeysView, ValuesView, Mapping
import logging import logging
import functools import functools
import copy
from collections import Counter from collections import Counter
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
from itertools import chain from itertools import chain
@ -91,6 +92,12 @@ class Port(PositionableImpl, Rotatable, PivotableImpl, Copyable, Flippable):
def copy(self) -> Self: def copy(self) -> Self:
return self.deepcopy() return self.deepcopy()
def __deepcopy__(self, memo: dict | None = None) -> Self:
memo = {} if memo is None else memo
new = copy.copy(self)
new._offset = self._offset.copy()
return new
def get_bounds(self) -> NDArray[numpy.float64]: def get_bounds(self) -> NDArray[numpy.float64]:
return numpy.vstack((self.offset, self.offset)) return numpy.vstack((self.offset, self.offset))