clean up magic numbers, enable arbitrary gridding, add cache invalidatino

This commit is contained in:
Jan Petykiewicz 2026-03-26 20:22:17 -07:00
commit 519dd48131

View file

@ -14,6 +14,8 @@ def snap_nm(value: float) -> float:
return round(value * 1000) / 1000
from inire.constants import TOLERANCE_LINEAR
class Port:
"""
A port defined by (x, y, orientation) in micrometers.
@ -46,12 +48,12 @@ class Port:
def __eq__(self, other: object) -> bool:
if not isinstance(other, Port):
return False
return (self.x == other.x and
self.y == other.y and
self.orientation == other.orientation)
return (abs(self.x - other.x) < TOLERANCE_LINEAR and
abs(self.y - other.y) < TOLERANCE_LINEAR and
abs(self.orientation - other.orientation) < TOLERANCE_LINEAR)
def __hash__(self) -> int:
return hash((self.x, self.y, self.orientation))
return hash((round(self.x, 6), round(self.y, 6), round(self.orientation, 6)))
def translate_port(port: Port, dx: float, dy: float) -> Port: