[AutoTool] fix some masked errors

This commit is contained in:
Jan Petykiewicz 2026-07-13 23:07:37 -07:00
commit 412133533a
2 changed files with 38 additions and 4 deletions

View file

@ -1190,10 +1190,7 @@ class AutoTool(Tool):
return Port((float(sbend_dxy[0]), float(jog)), rotation=pi, ptype=ptype)
else:
def endpoint_at(jog: float) -> Port:
out_port = endpoint(jog)
if not ptypes_compatible(out_port.ptype, ptype):
raise BuildError('S-bend endpoint ptype does not match registered ptype')
return out_port
return endpoint(jog)
for jog_domain in self._signed_jog_domains(jog_range):
def data_at(jog: float) -> AutoTool.GeneratedData:

View file

@ -8,6 +8,7 @@ from numpy.testing import assert_allclose
from masque.builder.tools import AutoTool, PrimitiveOffer, RenderStep, UOffer, circular_arc_sbend_endpoint
from masque.builder.pather import Pather
from masque.builder.error import ToolContractError
from masque.library import Library
from masque.pattern import Pattern
from masque.ports import Port
@ -522,6 +523,42 @@ def test_autotool_sbend_custom_endpoint_avoids_generator_during_planning() -> No
assert data.mirrored is False
def test_autotool_sbend_endpoint_ptype_mismatch_is_fatal() -> None:
def make_core_sbend(jog: float) -> Pattern:
return make_sbend(jog, ptype='core')
tool = (
AutoTool()
.add_straight(
lambda length: make_straight(length, ptype='core'),
'core',
'A',
)
.add_sbend(
make_core_sbend,
'core',
'A',
'B',
jog_range=(0, 20),
endpoint=lambda jog: Port((10, jog), pi, ptype='wrong'),
)
.add_sbend(
make_core_sbend,
'core',
'A',
'B',
jog_range=(0, 20),
)
)
pather = Pather(Library(), tools=tool, render='deferred')
pather.ports['A'] = Port((0, 0), 0, ptype='core')
with pytest.raises(ToolContractError, match='declared offer out_ptype'):
pather.jog('A', 4, length=20)
assert_allclose(pather.ports['A'].offset, (0, 0))
def test_circular_arc_sbend_endpoint() -> None:
endpoint = circular_arc_sbend_endpoint(radius=5, ptype="core")