Cleanup based on flake8 lint

This commit is contained in:
jan 2023-10-13 02:36:23 -07:00
parent dec084818a
commit bfd81f777c
6 changed files with 10 additions and 14 deletions

View File

@ -1,17 +1,15 @@
""" """
Simplified Pattern assembly (`Builder`) Simplified Pattern assembly (`Builder`)
""" """
from typing import Self, Sequence, Mapping, Literal, overload from typing import Self, Sequence, Mapping
import copy import copy
import logging import logging
from numpy import pi
from numpy.typing import ArrayLike from numpy.typing import ArrayLike
from ..pattern import Pattern from ..pattern import Pattern
from ..ref import Ref
from ..library import ILibrary from ..library import ILibrary
from ..error import PortError, BuildError from ..error import BuildError
from ..ports import PortList, Port from ..ports import PortList, Port
from ..abstract import Abstract from ..abstract import Abstract

View File

@ -399,12 +399,12 @@ class Pather(Builder):
is_horizontal = numpy.isclose(port.rotation % pi, 0) is_horizontal = numpy.isclose(port.rotation % pi, 0)
if is_horizontal: if is_horizontal:
if y is not None: if y is not None:
raise BuildError(f'Asked to path to y-coordinate, but port is horizontal') raise BuildError('Asked to path to y-coordinate, but port is horizontal')
if position is None: if position is None:
position = x position = x
else: else:
if x is not None: if x is not None:
raise BuildError(f'Asked to path to x-coordinate, but port is vertical') raise BuildError('Asked to path to x-coordinate, but port is vertical')
if position is None: if position is None:
position = y position = y

View File

@ -12,15 +12,13 @@ from numpy import pi
from numpy.typing import ArrayLike from numpy.typing import ArrayLike
from ..pattern import Pattern from ..pattern import Pattern
from ..ref import Ref from ..library import ILibrary
from ..library import ILibrary, Library
from ..error import PortError, BuildError from ..error import PortError, BuildError
from ..ports import PortList, Port from ..ports import PortList, Port
from ..abstract import Abstract from ..abstract import Abstract
from ..utils import SupportsBool from ..utils import SupportsBool
from .tools import Tool, RenderStep from .tools import Tool, RenderStep
from .utils import ell from .utils import ell
from .builder import Builder
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -491,12 +489,12 @@ class RenderPather(PortList):
is_horizontal = numpy.isclose(port.rotation % pi, 0) is_horizontal = numpy.isclose(port.rotation % pi, 0)
if is_horizontal: if is_horizontal:
if y is not None: if y is not None:
raise BuildError(f'Asked to path to y-coordinate, but port is horizontal') raise BuildError('Asked to path to y-coordinate, but port is horizontal')
if position is None: if position is None:
position = x position = x
else: else:
if x is not None: if x is not None:
raise BuildError(f'Asked to path to x-coordinate, but port is vertical') raise BuildError('Asked to path to x-coordinate, but port is vertical')
if position is None: if position is None:
position = y position = y

View File

@ -262,7 +262,6 @@ class BasicTool(Tool, metaclass=ABCMeta):
default_out_ptype: str default_out_ptype: str
""" Default value for out_ptype """ """ Default value for out_ptype """
@dataclass(frozen=True, slots=True) @dataclass(frozen=True, slots=True)
class LData: class LData:
""" Data for planL """ """ Data for planL """

View File

@ -122,6 +122,8 @@ def ell(
orig_offsets = numpy.array([p.offset for p in ports.values()]) orig_offsets = numpy.array([p.offset for p in ports.values()])
rot_offsets = (rot_matrix @ orig_offsets.T).T rot_offsets = (rot_matrix @ orig_offsets.T).T
# ordering_base = rot_offsets.T * [[1], [-1 if ccw else 1]] # could work, but this is actually a more complex routing problem
# y_order = numpy.lexsort(ordering_base) # (need to make sure we don't collide with the next input port @ same y)
y_order = ((-1 if ccw else 1) * rot_offsets[:, 1]).argsort(kind='stable') y_order = ((-1 if ccw else 1) * rot_offsets[:, 1]).argsort(kind='stable')
y_ind = numpy.empty_like(y_order, dtype=int) y_ind = numpy.empty_like(y_order, dtype=int)
y_ind[y_order] = numpy.arange(y_ind.shape[0]) y_ind[y_order] = numpy.arange(y_ind.shape[0])

View File

@ -1,6 +1,5 @@
from typing import Any from typing import Any
import copy import copy
import math
import numpy import numpy
from numpy import pi from numpy import pi
@ -231,7 +230,7 @@ class Arc(Shape):
def get_thetas(inner: bool) -> NDArray[numpy.float64]: def get_thetas(inner: bool) -> NDArray[numpy.float64]:
""" Figure out the parameter values at which we should place vertices to meet the arclength constraint""" """ Figure out the parameter values at which we should place vertices to meet the arclength constraint"""
dr = -self.width / 2.0 * (-1 if inner else 1) #dr = -self.width / 2.0 * (-1 if inner else 1)
n_pts = numpy.ceil(2 * pi * max(self.radii) / max_arclen).astype(int) n_pts = numpy.ceil(2 * pi * max(self.radii) / max_arclen).astype(int)
arc_lengths, thetas = get_arclens(n_pts, *a_ranges[0 if inner else 1]) arc_lengths, thetas = get_arclens(n_pts, *a_ranges[0 if inner else 1])