diff --git a/masque/builder/pather.py b/masque/builder/pather.py index 9af473d..3a0dee4 100644 --- a/masque/builder/pather.py +++ b/masque/builder/pather.py @@ -352,17 +352,16 @@ class Pather(Builder, PatherMixin): except NotImplementedError: # Fall back to drawing two L-bends ccw0 = jog > 0 - kwargs_no_out = kwargs | {'out_ptype': None} + kwargs_no_out = (kwargs | {'out_ptype': None}) t_tree0 = tool.path( ccw0, length / 2, port_names=tool_port_names, in_ptype=in_ptype, **kwargs_no_out) t_pat0 = t_tree0.top_pattern() (_, jog0), _ = t_pat0[tool_port_names[0]].measure_travel(t_pat0[tool_port_names[1]]) - t_tree1 = tool.path(not ccw0, abs(jog - jog0), port_names=tool_port_names, in_ptype=t_pat0[tool_port_names[1]].ptype, **kwargs) + t_tree1 = tool.path(not ccw0, jog - jog0, port_names=tool_port_names, in_ptype=t_pat0[tool_port_names[1]].ptype, **kwargs) t_pat1 = t_tree1.top_pattern() (_, jog1), _ = t_pat1[tool_port_names[0]].measure_travel(t_pat1[tool_port_names[1]]) - kwargs_plug = kwargs | {'plug_into': plug_into} - self.path(portspec, ccw0, length - abs(jog1), **kwargs_no_out) - self.path(portspec, not ccw0, abs(jog - jog0), **kwargs_plug) + self.path(portspec, ccw0, length - jog1, **kwargs_no_out) + self.path(portspec, not ccw0, jog - jog0, **kwargs) return self tname = self.library << tree diff --git a/masque/builder/pather_mixin.py b/masque/builder/pather_mixin.py index 6acd7c6..bcf9d5e 100644 --- a/masque/builder/pather_mixin.py +++ b/masque/builder/pather_mixin.py @@ -321,7 +321,7 @@ class PatherMixin(PortList, metaclass=ABCMeta): else: # S-bend, delegate to implementations (travel, jog), _ = port_src.measure_travel(port_dst) - self.pathS(portspec_src, -travel, -jog, **dst_args) + self.pathS(portspec_src, -travel, jog, **dst_args) elif numpy.isclose(angle, 0): raise BuildError('Don\'t know how to route a U-bend yet (TODO)!') else: diff --git a/masque/builder/renderpather.py b/masque/builder/renderpather.py index 303a59d..747a098 100644 --- a/masque/builder/renderpather.py +++ b/masque/builder/renderpather.py @@ -488,13 +488,12 @@ class RenderPather(PatherMixin): ccw0 = jog > 0 kwargs_no_out = (kwargs | {'out_ptype': None}) t_port0, _ = tool.planL( ccw0, length / 2, in_ptype=in_ptype, **kwargs_no_out) - jog0 = Port((0, 0), 0).measure_travel(t_port0)[0][1] - t_port1, _ = tool.planL(not ccw0, abs(jog - jog0), in_ptype=t_port0.ptype, **kwargs) - jog1 = Port((0, 0), 0).measure_travel(t_port1)[0][1] + (_, jog0), _ = Port((0, 0), 0).measure_travel(t_port0) + t_port1, _ = tool.planL(not ccw0, jog - jog0, in_ptype=t_port0.ptype, **kwargs) + (_, jog1), _ = Port((0, 0), 0).measure_travel(t_port1) - kwargs_plug = kwargs | {'plug_into': plug_into} - self.path(portspec, ccw0, length - abs(jog1), **kwargs_no_out) - self.path(portspec, not ccw0, abs(jog - jog0), **kwargs_plug) + self.path(portspec, ccw0, length - jog1, **kwargs_no_out) + self.path(portspec, not ccw0, jog - jog0, **kwargs) return self out_port.rotate_around((0, 0), pi + port_rot) diff --git a/masque/builder/tools.py b/masque/builder/tools.py index 6bd7547..9c27a41 100644 --- a/masque/builder/tools.py +++ b/masque/builder/tools.py @@ -768,7 +768,6 @@ class AutoTool(Tool, metaclass=ABCMeta): l2_err: BuildError | None = err else: l2_err = None - raise NotImplementedError('TODO need to handle ldata below') if not success: # Failed to break diff --git a/masque/pattern.py b/masque/pattern.py index d870a43..4a401b6 100644 --- a/masque/pattern.py +++ b/masque/pattern.py @@ -1169,13 +1169,12 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable): ports[new_name] = port for name, port in ports.items(): - pp = port.deepcopy() + p = port.deepcopy() if mirrored: - pp.mirror() - pp.offset[1] *= -1 - pp.rotate_around(pivot, rotation) - pp.translate(offset) - self.ports[name] = pp + p.mirror() + p.rotate_around(pivot, rotation) + p.translate(offset) + self.ports[name] = p if append: if isinstance(other, Abstract): diff --git a/masque/ports.py b/masque/ports.py index 0211723..b8137c0 100644 --- a/masque/ports.py +++ b/masque/ports.py @@ -100,6 +100,7 @@ class Port(PositionableImpl, Rotatable, PivotableImpl, Copyable, Mirrorable): return self def mirror(self, axis: int = 0) -> Self: + self.offset[1 - axis] *= -1 if self.rotation is not None: self.rotation *= -1 self.rotation += axis * pi