From 808766f5a92d91db6deffc23bb93d257905a6209 Mon Sep 17 00:00:00 2001 From: jan Date: Fri, 13 Oct 2023 02:31:52 -0700 Subject: [PATCH] No need for Builder --- masque/builder/tools.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/masque/builder/tools.py b/masque/builder/tools.py index 2ed56d6..f12ea7d 100644 --- a/masque/builder/tools.py +++ b/masque/builder/tools.py @@ -17,7 +17,6 @@ from ..pattern import Pattern from ..abstract import Abstract from ..library import ILibrary, Library from ..error import BuildError -from .builder import Builder @dataclass(frozen=True, slots=True) @@ -255,20 +254,20 @@ class BasicTool(Tool, metaclass=ABCMeta): ) gen_straight, sport_in, sport_out = self.straight - tree = Library() - bb = Builder(library=tree, name='_path').add_port_pair(names=port_names) + tree, pat = Library.mktree('_path') + pat.add_port_pair(names=port_names) if data.in_transition: ipat, iport_theirs, _iport_ours = data.in_transition - bb.plug(ipat, {port_names[1]: iport_theirs}) + pat.plug(ipat, {port_names[1]: iport_theirs}) if not numpy.isclose(data.straight_length, 0): - straight = tree << {'_straight': gen_straight(data.straight_length)} - bb.plug(straight, {port_names[1]: sport_in}) + straight = tree <= {'_straight': gen_straight(data.straight_length)} + pat.plug(straight, {port_names[1]: sport_in}) if data.ccw is not None: bend, bport_in, bport_out = self.bend - bb.plug(bend, {port_names[1]: bport_in}, mirrored=bool(ccw)) + pat.plug(bend, {port_names[1]: bport_in}, mirrored=bool(ccw)) if data.out_transition: opat, oport_theirs, oport_ours = data.out_transition - bb.plug(opat, {port_names[1]: oport_ours}) + pat.plug(opat, {port_names[1]: oport_ours}) return tree @@ -358,8 +357,8 @@ class BasicTool(Tool, metaclass=ABCMeta): **kwargs, ) -> ILibrary: - tree = Library() - bb = Builder(library=tree, name='_path').add_port_pair(names=(port_names[0], port_names[1])) + tree, pat = Library.mktree('_path') + pat.add_port_pair(names=(port_names[0], port_names[1])) gen_straight, sport_in, _sport_out = self.straight for step in batch: @@ -369,20 +368,20 @@ class BasicTool(Tool, metaclass=ABCMeta): if step.opcode == 'L': if in_transition: ipat, iport_theirs, _iport_ours = in_transition - bb.plug(ipat, {port_names[1]: iport_theirs}) + pat.plug(ipat, {port_names[1]: iport_theirs}) if not numpy.isclose(straight_length, 0): straight_pat = gen_straight(straight_length) if append: - bb.plug(straight_pat, {port_names[1]: sport_in}, append=True) + pat.plug(straight_pat, {port_names[1]: sport_in}, append=True) else: - straight = tree << {'_straight': straight_pat} - bb.plug(straight, {port_names[1]: sport_in}, append=True) + straight = tree <= {'_straight': straight_pat} + pat.plug(straight, {port_names[1]: sport_in}, append=True) if ccw is not None: bend, bport_in, bport_out = self.bend - bb.plug(bend, {port_names[1]: bport_in}, mirrored=bool(ccw)) + pat.plug(bend, {port_names[1]: bport_in}, mirrored=bool(ccw)) if out_transition: opat, oport_theirs, oport_ours = out_transition - bb.plug(opat, {port_names[1]: oport_ours}) + pat.plug(opat, {port_names[1]: oport_ours}) return tree