Auto-fit minimum (half_w, half_h) so the pin names fit without overlap: pins spaced ≥ side-spacing with corner margins, plus the name column/row stack. Horizontal-side spacing is wider than vertical (names are wider than tall). Rounded up to the grid.
(placement: list)
| 103 | |
| 104 | |
| 105 | def _min_half(placement: list) -> tuple[float, float]: |
| 106 | """Auto-fit minimum (half_w, half_h) so the pin names fit without overlap: |
| 107 | pins spaced ≥ side-spacing with corner margins, plus the name column/row |
| 108 | stack. Horizontal-side spacing is wider than vertical (names are wider than |
| 109 | tall). Rounded up to the grid.""" |
| 110 | n_top, n_right, n_bottom, n_left = _side_counts(len(placement)) |
| 111 | name_w = max((len(p) for p in placement), default=1) * _CHARW |
| 112 | space_h = _round_up(name_w + _NGAP, _STEP) # horizontal-side pin spacing (wide) |
| 113 | space_v = _round_up(_NAMEH + _NGAP, _STEP) # vertical-side pin spacing (narrow) |
| 114 | cols = bool(n_left) + bool(n_top or n_bottom) + bool(n_right) |
| 115 | rows = bool(n_top) + bool(n_left or n_right) + bool(n_bottom) |
| 116 | stack_w = cols * name_w + max(cols - 1, 0) * _NGAP |
| 117 | stack_h = rows * _NAMEH + max(rows - 1, 0) * _NGAP |
| 118 | half_w = _grid_up(max((max(n_top, n_bottom) - 1) * space_h / 2 + _CORNER, |
| 119 | stack_w / 2 + _NMARGIN, _MINH)) |
| 120 | half_h = _grid_up(max((max(n_left, n_right) - 1) * space_v / 2 + _CORNER, |
| 121 | stack_h / 2 + _NMARGIN, _MINH)) |
| 122 | return half_w, half_h |
| 123 | |
| 124 | |
| 125 | def min_half(defn: SubcktDef, placement: list | None = None) -> tuple[float, float]: |
no test coverage detected