Compare commits

..

No commits in common. "e75a76e5a8d7032f117ddb6b45829daa514c7b81" and "4dc81bd9f7bcfe50d78abfb3705c4d340a68bbb1" have entirely different histories.

4 changed files with 10 additions and 42 deletions

View File

@ -1,4 +1,4 @@
from typing import Self from typing import Self, TYPE_CHECKING
from collections.abc import Sequence, Iterator, Iterable from collections.abc import Sequence, Iterator, Iterable
import logging import logging
from contextlib import contextmanager from contextlib import contextmanager
@ -537,10 +537,6 @@ class PortPather:
self.pather[self.port].set_ptype(ptype) self.pather[self.port].set_ptype(ptype)
return self return self
def translate(self, *args, **kwargs) -> Self:
self.pather[self.port].translate(*args, **kwargs)
return self
def mirror(self, *args, **kwargs) -> Self: def mirror(self, *args, **kwargs) -> Self:
self.pather[self.port].mirror(*args, **kwargs) self.pather[self.port].mirror(*args, **kwargs)
return self return self
@ -560,13 +556,3 @@ class PortPather:
def rename_from(self, old_name: str) -> Self: def rename_from(self, old_name: str) -> Self:
self.pather.rename_ports({old_name: self.port}) self.pather.rename_ports({old_name: self.port})
return self 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

View File

@ -279,7 +279,6 @@ class RenderPather(PatherMixin):
thru = thru, thru = thru,
set_rotation = set_rotation, set_rotation = set_rotation,
append = append, append = append,
ok_connections = ok_connections,
) )
return self return self

View File

@ -302,9 +302,6 @@ class SimpleTool(Tool, metaclass=ABCMeta):
default_out_ptype: str default_out_ptype: str
""" Default value for out_ptype """ """ 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) @dataclass(frozen=True, slots=True)
class LData: class LData:
""" Data for planL """ """ Data for planL """
@ -381,13 +378,11 @@ class SimpleTool(Tool, metaclass=ABCMeta):
else: else:
straight_tree = straight_pat_or_tree straight_tree = straight_pat_or_tree
top = straight_tree.top() top = straight_tree.top()
straight_tree.flatten(top, dangling_ok=True) straight_tree.flatten(top)
pat.plug(straight_tree[top], pmap, append=True) pat.plug(straight_tree[top], pmap, append=True)
if data.ccw is not None: if data.ccw is not None:
bend, bport_in, bport_out = self.bend bend, bport_in, bport_out = self.bend
mirrored = self.mirror_bend and bool(data.ccw) pat.plug(bend, {port_names[1]: bport_in}, mirrored=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)
return tree return tree
def path( def path(
@ -468,8 +463,7 @@ class AutoTool(Tool, metaclass=ABCMeta):
abstract: Abstract abstract: Abstract
in_port_name: str in_port_name: str
out_port_name: str out_port_name: str
clockwise: bool = True # Is in-to-out clockwise? clockwise: bool = True
mirror: bool = True # Should we mirror to get the other rotation?
@property @property
def in_port(self) -> Port: def in_port(self) -> Port:
@ -659,16 +653,13 @@ class AutoTool(Tool, metaclass=ABCMeta):
else: else:
straight_tree = straight_pat_or_tree straight_tree = straight_pat_or_tree
top = straight_tree.top() top = straight_tree.top()
straight_tree.flatten(top, dangling_ok=True) straight_tree.flatten(top)
pat.plug(straight_tree[top], pmap, append=True) pat.plug(straight_tree[top], pmap, append=True)
if data.b_transition: if data.b_transition:
pat.plug(data.b_transition.abstract, {port_names[1]: data.b_transition.our_port_name}) pat.plug(data.b_transition.abstract, {port_names[1]: data.b_transition.our_port_name})
if data.ccw is not None: if data.ccw is not None:
bend = data.bend assert data.bend is not None
assert bend is not None pat.plug(data.bend.abstract, {port_names[1]: data.bend.in_port_name}, mirrored=bool(data.ccw) == data.bend.clockwise)
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)
if data.out_transition: if data.out_transition:
pat.plug(data.out_transition.abstract, {port_names[1]: data.out_transition.our_port_name}) pat.plug(data.out_transition.abstract, {port_names[1]: data.out_transition.our_port_name})
return tree return tree
@ -810,7 +801,7 @@ class AutoTool(Tool, metaclass=ABCMeta):
else: else:
straight_tree = straight_pat_or_tree straight_tree = straight_pat_or_tree
top = straight_tree.top() top = straight_tree.top()
straight_tree.flatten(top, dangling_ok=True) straight_tree.flatten(top)
pat.plug(straight_tree[top], pmap, append=True) pat.plug(straight_tree[top], pmap, append=True)
if data.b_transition: if data.b_transition:
pat.plug(data.b_transition.abstract, {port_names[1]: data.b_transition.our_port_name}) 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: else:
sbend_tree = sbend_pat_or_tree sbend_tree = sbend_pat_or_tree
top = sbend_tree.top() 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) pat.plug(sbend_tree[top], pmap, append=True, mirrored=data.jog_remaining < 0)
if data.out_transition: if data.out_transition:
pat.plug(data.out_transition.abstract, {port_names[1]: data.out_transition.our_port_name}) pat.plug(data.out_transition.abstract, {port_names[1]: data.out_transition.our_port_name})

View File

@ -264,7 +264,6 @@ class ILibraryView(Mapping[str, 'Pattern'], metaclass=ABCMeta):
self, self,
tops: str | Sequence[str], tops: str | Sequence[str],
flatten_ports: bool = False, flatten_ports: bool = False,
dangling_ok: bool = False,
) -> dict[str, 'Pattern']: ) -> dict[str, 'Pattern']:
""" """
Returns copies of all `tops` patterns with all refs 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. tops: The pattern(s) to flattern.
flatten_ports: If `True`, keep ports from any referenced flatten_ports: If `True`, keep ports from any referenced
patterns; otherwise discard them. 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: Returns:
{name: flat_pattern} mapping for all flattened patterns. {name: flat_pattern} mapping for all flattened patterns.
@ -296,8 +292,6 @@ class ILibraryView(Mapping[str, 'Pattern'], metaclass=ABCMeta):
for target in pat.refs: for target in pat.refs:
if target is None: if target is None:
continue continue
if dangling_ok and target not in self:
continue
if target not in flattened: if target not in flattened:
flatten_single(target) flatten_single(target)
@ -313,9 +307,7 @@ class ILibraryView(Mapping[str, 'Pattern'], metaclass=ABCMeta):
p.ports.clear() p.ports.clear()
pat.append(p) pat.append(p)
for target in set(pat.refs.keys()) & set(self.keys()): pat.refs.clear()
del pat.refs[target]
flattened[name] = pat flattened[name] = pat
for top in tops: for top in tops: