From 412133533ad1a8f65279e6c5944b222176337bba Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Mon, 13 Jul 2026 23:07:37 -0700 Subject: [PATCH] [AutoTool] fix some masked errors --- masque/builder/tools.py | 5 +--- masque/test/test_autotool_planning.py | 37 +++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/masque/builder/tools.py b/masque/builder/tools.py index 125140e..b5ca9ca 100644 --- a/masque/builder/tools.py +++ b/masque/builder/tools.py @@ -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: diff --git a/masque/test/test_autotool_planning.py b/masque/test/test_autotool_planning.py index a0979ce..2a868fd 100644 --- a/masque/test/test_autotool_planning.py +++ b/masque/test/test_autotool_planning.py @@ -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")