[AutoTool] pass in kwargs to straight fn call

This commit is contained in:
Jan Petykiewicz 2025-11-13 00:01:12 -08:00
parent 2a8879e3d4
commit d37e6b873c

View File

@ -492,6 +492,7 @@ class AutoTool(Tool, metaclass=ABCMeta):
""" Data for planL """ """ Data for planL """
straight_length: float straight_length: float
straight: 'AutoTool.Straight' straight: 'AutoTool.Straight'
straight_kwargs: dict[str, Any]
ccw: SupportsBool | None ccw: SupportsBool | None
bend: 'AutoTool.Bend | None' bend: 'AutoTool.Bend | None'
in_transition: 'AutoTool.Transition | None' in_transition: 'AutoTool.Transition | None'
@ -605,7 +606,7 @@ class AutoTool(Tool, metaclass=ABCMeta):
else: else:
out_ptype_actual = self.default_out_ptype out_ptype_actual = self.default_out_ptype
data = self.LData(straight_length, straight, ccw, bend, in_transition, b_transition, out_transition) data = self.LData(straight_length, straight, straight_kwargs, ccw, bend, in_transition, b_transition, out_transition)
out_port = Port((length, bend_run), rotation=bend_angle, ptype=out_ptype_actual) out_port = Port((length, bend_run), rotation=bend_angle, ptype=out_ptype_actual)
return out_port, data return out_port, data
@ -615,6 +616,7 @@ class AutoTool(Tool, metaclass=ABCMeta):
tree: ILibrary, tree: ILibrary,
port_names: tuple[str, str], port_names: tuple[str, str],
append: bool, append: bool,
straight_kwargs: dict[str, Any],
) -> ILibrary: ) -> ILibrary:
""" """
Render an L step into a preexisting tree Render an L step into a preexisting tree
@ -623,7 +625,7 @@ class AutoTool(Tool, metaclass=ABCMeta):
if data.in_transition: if data.in_transition:
pat.plug(data.in_transition.abstract, {port_names[1]: data.in_transition.their_port_name}) pat.plug(data.in_transition.abstract, {port_names[1]: data.in_transition.their_port_name})
if not numpy.isclose(data.straight_length, 0): if not numpy.isclose(data.straight_length, 0):
straight_pat_or_tree = data.straight.fn(data.straight_length, **kwargs) straight_pat_or_tree = data.straight.fn(data.straight_length, **(straight_kwargs | data.straight_kwargs))
pmap = {port_names[1]: data.straight.in_port_name} pmap = {port_names[1]: data.straight.in_port_name}
if isinstance(straight_pat_or_tree, Pattern): if isinstance(straight_pat_or_tree, Pattern):
straight_pat = straight_pat_or_tree straight_pat = straight_pat_or_tree
@ -668,7 +670,7 @@ class AutoTool(Tool, metaclass=ABCMeta):
tree, pat = Library.mktree(SINGLE_USE_PREFIX + 'path') tree, pat = Library.mktree(SINGLE_USE_PREFIX + 'path')
pat.add_port_pair(names=port_names, ptype='unk' if in_ptype is None else in_ptype) pat.add_port_pair(names=port_names, ptype='unk' if in_ptype is None else in_ptype)
self._renderL(data=data, tree=tree, port_names=port_names, append=False) self._renderL(data=data, tree=tree, port_names=port_names, append=False, straight_kwargs=kwargs)
return tree return tree
def render( def render(
@ -686,7 +688,7 @@ class AutoTool(Tool, metaclass=ABCMeta):
for step in batch: for step in batch:
assert step.tool == self assert step.tool == self
if step.opcode == 'L': if step.opcode == 'L':
self._renderL(data=step.data, tree=tree, port_names=port_names, append=append) self._renderL(data=step.data, tree=tree, port_names=port_names, append=append, straight_kwargs=kwargs)
return tree return tree