[Tool] avoid passing port_names down
This commit is contained in:
parent
707a16fe64
commit
20c845a881
2 changed files with 33 additions and 3 deletions
|
|
@ -240,7 +240,7 @@ class Tool:
|
|||
BuildError if an impossible or unsupported geometry is requested.
|
||||
"""
|
||||
# Fallback implementation using traceL
|
||||
port_names = kwargs.get('port_names', ('A', 'B'))
|
||||
port_names = kwargs.pop('port_names', ('A', 'B'))
|
||||
tree = self.traceL(
|
||||
ccw,
|
||||
length,
|
||||
|
|
@ -288,7 +288,7 @@ class Tool:
|
|||
BuildError if an impossible or unsupported geometry is requested.
|
||||
"""
|
||||
# Fallback implementation using traceS
|
||||
port_names = kwargs.get('port_names', ('A', 'B'))
|
||||
port_names = kwargs.pop('port_names', ('A', 'B'))
|
||||
tree = self.traceS(
|
||||
length,
|
||||
jog,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import pytest
|
|||
import numpy
|
||||
from numpy import pi
|
||||
from masque import Pather, RenderPather, Library, Pattern, Port
|
||||
from masque.builder.tools import PathTool
|
||||
from masque.builder.tools import PathTool, Tool
|
||||
from masque.error import BuildError
|
||||
|
||||
def test_pather_trace_basic() -> None:
|
||||
|
|
@ -258,6 +258,36 @@ def test_pather_jog_failed_fallback_is_atomic() -> None:
|
|||
assert len(p.paths['A']) == 0
|
||||
|
||||
|
||||
def test_tool_planL_fallback_accepts_custom_port_names() -> None:
|
||||
class DummyTool(Tool):
|
||||
def traceL(self, ccw, length, *, in_ptype=None, out_ptype=None, port_names=('A', 'B'), **kwargs) -> Library:
|
||||
lib = Library()
|
||||
pat = Pattern()
|
||||
pat.ports[port_names[0]] = Port((0, 0), 0, ptype='wire')
|
||||
pat.ports[port_names[1]] = Port((length, 0), pi, ptype='wire')
|
||||
lib['top'] = pat
|
||||
return lib
|
||||
|
||||
out_port, _ = DummyTool().planL(None, 5, port_names=('X', 'Y'))
|
||||
assert numpy.allclose(out_port.offset, (5, 0))
|
||||
assert numpy.isclose(out_port.rotation, pi)
|
||||
|
||||
|
||||
def test_tool_planS_fallback_accepts_custom_port_names() -> None:
|
||||
class DummyTool(Tool):
|
||||
def traceS(self, length, jog, *, in_ptype=None, out_ptype=None, port_names=('A', 'B'), **kwargs) -> Library:
|
||||
lib = Library()
|
||||
pat = Pattern()
|
||||
pat.ports[port_names[0]] = Port((0, 0), 0, ptype='wire')
|
||||
pat.ports[port_names[1]] = Port((length, jog), pi, ptype='wire')
|
||||
lib['top'] = pat
|
||||
return lib
|
||||
|
||||
out_port, _ = DummyTool().planS(5, 2, port_names=('X', 'Y'))
|
||||
assert numpy.allclose(out_port.offset, (5, 2))
|
||||
assert numpy.isclose(out_port.rotation, pi)
|
||||
|
||||
|
||||
def test_pather_uturn_failed_fallback_is_atomic() -> None:
|
||||
lib = Library()
|
||||
tool = PathTool(layer='M1', width=2, ptype='wire')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue