path() should return a tree
This commit is contained in:
		
							parent
							
								
									5001664547
								
							
						
					
					
						commit
						80e0c5daa8
					
				@ -324,10 +324,10 @@ class Pather(Builder):
 | 
			
		||||
 | 
			
		||||
        tool = self.tools.get(portspec, self.tools[None])
 | 
			
		||||
        in_ptype = self.pattern[portspec].ptype
 | 
			
		||||
        pat = tool.path(ccw, length, in_ptype=in_ptype, port_names=tool_port_names, **kwargs)
 | 
			
		||||
        tree = tool.path(ccw, length, in_ptype=in_ptype, port_names=tool_port_names, **kwargs)
 | 
			
		||||
        name = self.library.get_name(base_name)
 | 
			
		||||
        self.library[name] = pat
 | 
			
		||||
        return self.plug(Abstract(name, pat.ports), {portspec: tool_port_names[0]})
 | 
			
		||||
        abstract = self.library << tree.rename_top(name)
 | 
			
		||||
        return self.plug(abstract, {portspec: tool_port_names[0]})
 | 
			
		||||
 | 
			
		||||
    def path_to(
 | 
			
		||||
            self,
 | 
			
		||||
 | 
			
		||||
@ -65,7 +65,7 @@ class Tool:
 | 
			
		||||
            out_ptype: str | None = None,
 | 
			
		||||
            port_names: tuple[str, str] = ('A', 'B'),
 | 
			
		||||
            **kwargs,
 | 
			
		||||
            ) -> Pattern:
 | 
			
		||||
            ) -> Library:
 | 
			
		||||
        """
 | 
			
		||||
        Create a wire or waveguide that travels exactly `length` distance along the axis
 | 
			
		||||
        of its input port.
 | 
			
		||||
@ -246,7 +246,7 @@ class BasicTool(Tool, metaclass=ABCMeta):
 | 
			
		||||
            out_ptype: str | None = None,
 | 
			
		||||
            port_names: tuple[str, str] = ('A', 'B'),
 | 
			
		||||
            **kwargs,
 | 
			
		||||
            ) -> Pattern:
 | 
			
		||||
            ) -> Library:
 | 
			
		||||
        _out_port, data = self.planL(
 | 
			
		||||
            ccw,
 | 
			
		||||
            length,
 | 
			
		||||
@ -270,7 +270,7 @@ class BasicTool(Tool, metaclass=ABCMeta):
 | 
			
		||||
            opat, oport_theirs, oport_ours = data.out_transition
 | 
			
		||||
            bb.plug(opat, {port_names[1]: oport_ours})
 | 
			
		||||
 | 
			
		||||
        return bb.pattern
 | 
			
		||||
        return tree
 | 
			
		||||
 | 
			
		||||
    def planL(
 | 
			
		||||
            self,
 | 
			
		||||
@ -422,7 +422,7 @@ class PathTool(Tool, metaclass=ABCMeta):
 | 
			
		||||
            out_ptype: str | None = None,
 | 
			
		||||
            port_names: tuple[str, str] = ('A', 'B'),
 | 
			
		||||
            **kwargs,
 | 
			
		||||
            ) -> Pattern:
 | 
			
		||||
            ) -> Library:
 | 
			
		||||
        out_port, dxy = self.planL(
 | 
			
		||||
            ccw,
 | 
			
		||||
            length,
 | 
			
		||||
@ -430,7 +430,7 @@ class PathTool(Tool, metaclass=ABCMeta):
 | 
			
		||||
            out_ptype=out_ptype,
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        pat = Pattern()
 | 
			
		||||
        tree, pat = Library.mktree('_path')
 | 
			
		||||
        pat.path(layer=self.layer, width=self.width, vertices=[(0, 0), (length, 0)])
 | 
			
		||||
 | 
			
		||||
        if ccw is None:
 | 
			
		||||
@ -445,7 +445,7 @@ class PathTool(Tool, metaclass=ABCMeta):
 | 
			
		||||
            port_names[1]: Port(dxy, rotation=out_rot, ptype=self.ptype),
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        return pat
 | 
			
		||||
        return tree
 | 
			
		||||
 | 
			
		||||
    def planL(
 | 
			
		||||
            self,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user