Compare commits
No commits in common. "e75a76e5a8d7032f117ddb6b45829daa514c7b81" and "4dc81bd9f7bcfe50d78abfb3705c4d340a68bbb1" have entirely different histories.
e75a76e5a8
...
4dc81bd9f7
@ -1,4 +1,4 @@
|
||||
from typing import Self
|
||||
from typing import Self, TYPE_CHECKING
|
||||
from collections.abc import Sequence, Iterator, Iterable
|
||||
import logging
|
||||
from contextlib import contextmanager
|
||||
@ -537,10 +537,6 @@ class PortPather:
|
||||
self.pather[self.port].set_ptype(ptype)
|
||||
return self
|
||||
|
||||
def translate(self, *args, **kwargs) -> Self:
|
||||
self.pather[self.port].translate(*args, **kwargs)
|
||||
return self
|
||||
|
||||
def mirror(self, *args, **kwargs) -> Self:
|
||||
self.pather[self.port].mirror(*args, **kwargs)
|
||||
return self
|
||||
@ -560,13 +556,3 @@ class PortPather:
|
||||
def rename_from(self, old_name: str) -> Self:
|
||||
self.pather.rename_ports({old_name: self.port})
|
||||
return self
|
||||
|
||||
def into_copy(self, new_name: str) -> Self:
|
||||
self.pather.ports[new_name] = self.pather[self.port].copy()
|
||||
self.port = new_name
|
||||
return self
|
||||
|
||||
def save_copy(self, new_name: str) -> Self:
|
||||
self.pather.ports[new_name] = self.pather[self.port].copy()
|
||||
return self
|
||||
|
||||
|
||||
@ -279,7 +279,6 @@ class RenderPather(PatherMixin):
|
||||
thru = thru,
|
||||
set_rotation = set_rotation,
|
||||
append = append,
|
||||
ok_connections = ok_connections,
|
||||
)
|
||||
|
||||
return self
|
||||
|
||||
@ -302,9 +302,6 @@ class SimpleTool(Tool, metaclass=ABCMeta):
|
||||
default_out_ptype: str
|
||||
""" Default value for out_ptype """
|
||||
|
||||
mirror_bend: bool = True
|
||||
""" Whether a clockwise bend should be mirrored (vs rotated) to get a ccw bend """
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class LData:
|
||||
""" Data for planL """
|
||||
@ -381,13 +378,11 @@ class SimpleTool(Tool, metaclass=ABCMeta):
|
||||
else:
|
||||
straight_tree = straight_pat_or_tree
|
||||
top = straight_tree.top()
|
||||
straight_tree.flatten(top, dangling_ok=True)
|
||||
straight_tree.flatten(top)
|
||||
pat.plug(straight_tree[top], pmap, append=True)
|
||||
if data.ccw is not None:
|
||||
bend, bport_in, bport_out = self.bend
|
||||
mirrored = self.mirror_bend and bool(data.ccw)
|
||||
inport = bport_in if (self.mirror_bend or not data.ccw) else bport_out
|
||||
pat.plug(bend, {port_names[1]: inport}, mirrored=mirrored)
|
||||
pat.plug(bend, {port_names[1]: bport_in}, mirrored=bool(data.ccw))
|
||||
return tree
|
||||
|
||||
def path(
|
||||
@ -468,8 +463,7 @@ class AutoTool(Tool, metaclass=ABCMeta):
|
||||
abstract: Abstract
|
||||
in_port_name: str
|
||||
out_port_name: str
|
||||
clockwise: bool = True # Is in-to-out clockwise?
|
||||
mirror: bool = True # Should we mirror to get the other rotation?
|
||||
clockwise: bool = True
|
||||
|
||||
@property
|
||||
def in_port(self) -> Port:
|
||||
@ -659,16 +653,13 @@ class AutoTool(Tool, metaclass=ABCMeta):
|
||||
else:
|
||||
straight_tree = straight_pat_or_tree
|
||||
top = straight_tree.top()
|
||||
straight_tree.flatten(top, dangling_ok=True)
|
||||
straight_tree.flatten(top)
|
||||
pat.plug(straight_tree[top], pmap, append=True)
|
||||
if data.b_transition:
|
||||
pat.plug(data.b_transition.abstract, {port_names[1]: data.b_transition.our_port_name})
|
||||
if data.ccw is not None:
|
||||
bend = data.bend
|
||||
assert bend is not None
|
||||
mirrored = bend.mirror and (bool(data.ccw) == bend.clockwise)
|
||||
inport = bend.in_port_name if (bend.mirror or bool(data.ccw) != bend.clockwise) else bend.out_port_name
|
||||
pat.plug(bend.abstract, {port_names[1]: inport}, mirrored=mirrored)
|
||||
assert data.bend is not None
|
||||
pat.plug(data.bend.abstract, {port_names[1]: data.bend.in_port_name}, mirrored=bool(data.ccw) == data.bend.clockwise)
|
||||
if data.out_transition:
|
||||
pat.plug(data.out_transition.abstract, {port_names[1]: data.out_transition.our_port_name})
|
||||
return tree
|
||||
@ -810,7 +801,7 @@ class AutoTool(Tool, metaclass=ABCMeta):
|
||||
else:
|
||||
straight_tree = straight_pat_or_tree
|
||||
top = straight_tree.top()
|
||||
straight_tree.flatten(top, dangling_ok=True)
|
||||
straight_tree.flatten(top)
|
||||
pat.plug(straight_tree[top], pmap, append=True)
|
||||
if data.b_transition:
|
||||
pat.plug(data.b_transition.abstract, {port_names[1]: data.b_transition.our_port_name})
|
||||
@ -822,7 +813,7 @@ class AutoTool(Tool, metaclass=ABCMeta):
|
||||
else:
|
||||
sbend_tree = sbend_pat_or_tree
|
||||
top = sbend_tree.top()
|
||||
sbend_tree.flatten(top, dangling_ok=True)
|
||||
sbend_tree.flatten(top)
|
||||
pat.plug(sbend_tree[top], pmap, append=True, mirrored=data.jog_remaining < 0)
|
||||
if data.out_transition:
|
||||
pat.plug(data.out_transition.abstract, {port_names[1]: data.out_transition.our_port_name})
|
||||
|
||||
@ -264,7 +264,6 @@ class ILibraryView(Mapping[str, 'Pattern'], metaclass=ABCMeta):
|
||||
self,
|
||||
tops: str | Sequence[str],
|
||||
flatten_ports: bool = False,
|
||||
dangling_ok: bool = False,
|
||||
) -> dict[str, 'Pattern']:
|
||||
"""
|
||||
Returns copies of all `tops` patterns with all refs
|
||||
@ -277,9 +276,6 @@ class ILibraryView(Mapping[str, 'Pattern'], metaclass=ABCMeta):
|
||||
tops: The pattern(s) to flattern.
|
||||
flatten_ports: If `True`, keep ports from any referenced
|
||||
patterns; otherwise discard them.
|
||||
dangling_ok: If `True`, no error will be thrown if any
|
||||
ref points to a name which is not present in the library.
|
||||
Default False.
|
||||
|
||||
Returns:
|
||||
{name: flat_pattern} mapping for all flattened patterns.
|
||||
@ -296,8 +292,6 @@ class ILibraryView(Mapping[str, 'Pattern'], metaclass=ABCMeta):
|
||||
for target in pat.refs:
|
||||
if target is None:
|
||||
continue
|
||||
if dangling_ok and target not in self:
|
||||
continue
|
||||
if target not in flattened:
|
||||
flatten_single(target)
|
||||
|
||||
@ -313,9 +307,7 @@ class ILibraryView(Mapping[str, 'Pattern'], metaclass=ABCMeta):
|
||||
p.ports.clear()
|
||||
pat.append(p)
|
||||
|
||||
for target in set(pat.refs.keys()) & set(self.keys()):
|
||||
del pat.refs[target]
|
||||
|
||||
pat.refs.clear()
|
||||
flattened[name] = pat
|
||||
|
||||
for top in tops:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user