MCPcopy Create free account
hub / github.com/SLiCAP/SLiCAP_python / _spread

Function _spread

SLiCAP/schematic/subcircuit.py:130–142  ·  view source on GitHub ↗

``k`` pin offsets evenly spread along a side of half-length ``half``, symmetric about the centre, ≥ ``_CORNER`` from each corner, on the grid. Spacing is a multiple of ``_STEP`` (so offsets stay on the grid for any pin count) and as wide as fits the side; it never drops below ``_STEP``.

(k: int, half: float)

Source from the content-addressed store, hash-verified

128
129
130def _spread(k: int, half: float) -> list[float]:
131 """``k`` pin offsets evenly spread along a side of half-length ``half``,
132 symmetric about the centre, ≥ ``_CORNER`` from each corner, on the grid.
133
134 Spacing is a multiple of ``_STEP`` (so offsets stay on the grid for any pin
135 count) and as wide as fits the side; it never drops below ``_STEP``."""
136 if k <= 0:
137 return []
138 if k == 1:
139 return [0.0]
140 avail = max(0.0, 2 * (half - _CORNER))
141 step = max(_STEP, math.floor(avail / (k - 1) / _STEP) * _STEP)
142 return [(i - (k - 1) / 2) * step for i in range(k)]
143
144
145def box_symbol_svg(defn: SubcktDef, placement: list | None = None,

Callers 1

box_symbol_svgFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected