flatten indentation where it makes sense
This commit is contained in:
parent
9d5b1ef5e6
commit
39d9b88fa4
@ -658,7 +658,7 @@ class Pather(Builder):
|
||||
|
||||
if not bound_types:
|
||||
raise BuildError('No bound type specified for mpath')
|
||||
elif len(bound_types) > 1:
|
||||
if len(bound_types) > 1:
|
||||
raise BuildError(f'Too many bound types specified for mpath: {bound_types}')
|
||||
bound_type = tuple(bound_types)[0]
|
||||
|
||||
@ -672,13 +672,13 @@ class Pather(Builder):
|
||||
# Not a bus, so having a container just adds noise to the layout
|
||||
port_name = tuple(portspec)[0]
|
||||
return self.path(port_name, ccw, extensions[port_name], tool_port_names=tool_port_names, **kwargs)
|
||||
else:
|
||||
bld = Pather.interface(source=ports, library=self.library, tools=self.tools)
|
||||
for port_name, length in extensions.items():
|
||||
bld.path(port_name, ccw, length, tool_port_names=tool_port_names, **kwargs)
|
||||
name = self.library.get_name(base_name)
|
||||
self.library[name] = bld.pattern
|
||||
return self.plug(Abstract(name, bld.pattern.ports), {sp: 'in_' + sp for sp in ports.keys()}) # TODO safe to use 'in_'?
|
||||
|
||||
bld = Pather.interface(source=ports, library=self.library, tools=self.tools)
|
||||
for port_name, length in extensions.items():
|
||||
bld.path(port_name, ccw, length, tool_port_names=tool_port_names, **kwargs)
|
||||
name = self.library.get_name(base_name)
|
||||
self.library[name] = bld.pattern
|
||||
return self.plug(Abstract(name, bld.pattern.ports), {sp: 'in_' + sp for sp in ports}) # TODO safe to use 'in_'?
|
||||
|
||||
# TODO def bus_join()?
|
||||
|
||||
|
@ -561,7 +561,7 @@ class RenderPather(PortList):
|
||||
|
||||
if not bound_types:
|
||||
raise BuildError('No bound type specified for mpath')
|
||||
elif len(bound_types) > 1:
|
||||
if len(bound_types) > 1:
|
||||
raise BuildError(f'Too many bound types specified for mpath: {bound_types}')
|
||||
bound_type = tuple(bound_types)[0]
|
||||
|
||||
|
@ -113,7 +113,7 @@ def ell(
|
||||
is_horizontal = numpy.isclose(rotations[0] % pi, 0)
|
||||
if bound_type in ('ymin', 'ymax') and is_horizontal:
|
||||
raise BuildError(f'Asked for {bound_type} position but ports are pointing along the x-axis!')
|
||||
elif bound_type in ('xmin', 'xmax') and not is_horizontal:
|
||||
if bound_type in ('xmin', 'xmax') and not is_horizontal:
|
||||
raise BuildError(f'Asked for {bound_type} position but ports are pointing along the y-axis!')
|
||||
|
||||
direction = rotations[0] + pi # direction we want to travel in (+pi relative to port)
|
||||
|
@ -220,11 +220,11 @@ def _read_block(block) -> tuple[str, Pattern]:
|
||||
|
||||
if points.shape[1] == 2:
|
||||
raise PatternError('Invalid or unimplemented polygon?')
|
||||
#shape = Polygon()
|
||||
elif points.shape[1] > 2:
|
||||
|
||||
if points.shape[1] > 2:
|
||||
if (points[0, 2] != points[:, 2]).any():
|
||||
raise PatternError('PolyLine has non-constant width (not yet representable in masque!)')
|
||||
elif points.shape[1] == 4 and (points[:, 3] != 0).any():
|
||||
if points.shape[1] == 4 and (points[:, 3] != 0).any():
|
||||
raise PatternError('LWPolyLine has bulge (not yet representable in masque!)')
|
||||
|
||||
width = points[0, 2]
|
||||
|
@ -604,7 +604,7 @@ def load_libraryfile(
|
||||
else:
|
||||
gz_stream = gzip.open(path, mode='rb')
|
||||
stream = io.BufferedReader(gz_stream) # type: ignore
|
||||
else:
|
||||
else: # noqa: PLR5501
|
||||
if mmap:
|
||||
base_stream = open(path, mode='rb', buffering=0)
|
||||
stream = mmap.mmap(base_stream.fileno(), 0, access=mmap.ACCESS_READ) # type: ignore
|
||||
|
@ -181,7 +181,7 @@ class PortList(metaclass=ABCMeta):
|
||||
"""
|
||||
if isinstance(key, str):
|
||||
return self.ports[key]
|
||||
else:
|
||||
else: # noqa: RET505
|
||||
return {k: self.ports[k] for k in key}
|
||||
|
||||
def __contains__(self, key: str) -> NoReturn:
|
||||
|
@ -101,8 +101,7 @@ class Grid(Repetition):
|
||||
if b_vector is None:
|
||||
if b_count > 1:
|
||||
raise PatternError('Repetition has b_count > 1 but no b_vector')
|
||||
else:
|
||||
b_vector = numpy.array([0.0, 0.0])
|
||||
b_vector = numpy.array([0.0, 0.0])
|
||||
|
||||
if a_count < 1:
|
||||
raise PatternError(f'Repetition has too-small a_count: {a_count}')
|
||||
|
@ -253,7 +253,7 @@ class Polygon(Shape):
|
||||
lx = 2 * (xmax - xctr)
|
||||
else:
|
||||
raise PatternError('Two of xmin, xctr, xmax, lx must be None!')
|
||||
else:
|
||||
else: # noqa: PLR5501
|
||||
if xctr is not None:
|
||||
pass
|
||||
elif xmax is None:
|
||||
@ -283,7 +283,7 @@ class Polygon(Shape):
|
||||
ly = 2 * (ymax - yctr)
|
||||
else:
|
||||
raise PatternError('Two of ymin, yctr, ymax, ly must be None!')
|
||||
else:
|
||||
else: # noqa: PLR5501
|
||||
if yctr is not None:
|
||||
pass
|
||||
elif ymax is None:
|
||||
|
@ -12,7 +12,7 @@ def annotation2key(aaa: int | float | str) -> tuple[bool, Any]:
|
||||
def annotations_lt(aa: annotations_t, bb: annotations_t) -> bool:
|
||||
if aa is None:
|
||||
return bb is not None
|
||||
elif bb is None:
|
||||
elif bb is None: # noqa: RET505
|
||||
return False
|
||||
|
||||
if len(aa) != len(bb):
|
||||
@ -38,7 +38,7 @@ def annotations_lt(aa: annotations_t, bb: annotations_t) -> bool:
|
||||
def annotations_eq(aa: annotations_t, bb: annotations_t) -> bool:
|
||||
if aa is None:
|
||||
return bb is None
|
||||
elif bb is None:
|
||||
elif bb is None: # noqa: RET505
|
||||
return False
|
||||
|
||||
if len(aa) != len(bb):
|
||||
|
@ -70,8 +70,7 @@ def maxrects_bssf(
|
||||
if allow_rejects:
|
||||
rejected_inds.add(rect_ind)
|
||||
continue
|
||||
else:
|
||||
raise MasqueError(f'Failed to find a suitable location for rectangle {rect_ind}')
|
||||
raise MasqueError(f'Failed to find a suitable location for rectangle {rect_ind}')
|
||||
|
||||
# Read out location
|
||||
loc = regions[rr, :2]
|
||||
@ -161,8 +160,7 @@ def guillotine_bssf_sas(
|
||||
if allow_rejects:
|
||||
rejected_inds.add(rect_ind)
|
||||
continue
|
||||
else:
|
||||
raise MasqueError(f'Failed to find a suitable location for rectangle {rect_ind}')
|
||||
raise MasqueError(f'Failed to find a suitable location for rectangle {rect_ind}')
|
||||
|
||||
# Read out location
|
||||
loc = regions[rr, :2]
|
||||
|
Loading…
Reference in New Issue
Block a user