grid_layout module#

class GridPosition(row, column, pose)[source]#

Grid Position

This class represents a position in a grid of pads as well as a pose for the pad at that position. This is used by the GridLandpatternGenerator classes during the construction of a landpattern.

Parameters:
row: int#

The row of the grid position, zero-indexed.

column: int#

The column of the grid position, zero-indexed.

pose: Transform#

The pose of the pad at the grid position.

class GridLayout[source]#
class GridLayoutInterface[source]#

Bases: GridLayout, LandpatternProvider

class A1[source]#

Bases: GridLayoutInterface

Simple utility mixin to offset the minor index to start at 1 instead of 0, e.g. A[1]. Note that this offsets the minor index, which is typically but not always the column, and the order matters if using a numbering mixin that changes that, going before such mixins as ColumnMajorOrder.

class ColumnMajorOrder[source]#

Bases: GridLayoutInterface

Simple utility mixin to index the grid in column-major order instead of row-major order.

to_bga_row_ref(row)[source]#

Convert a row number into a alpha row reference

This function converts a zero-indexed row ordinal to a BGA-style alpha row reference string. The letters I, O, Q, S, X, and Z are skipped.

Return type:

str

Parameters:

row (int)

For example:

0 -> “A” 1 -> “B” 19 -> “Y” 20 -> “AA” 39 -> “AY” 40 -> “BA” 419 -> “YY” 420 -> “AAA”

class AlphaDictNumberingBase[source]#

Bases: GridLayoutInterface

Base class to provide a BGA-style alpha-numeric dictionary numbering scheme. The row is referred to by a letter as a member field, and the column is referred to by a number inside the dictionary at that field. No predefined rows are provided, and the intent is that this class is subclassed with declarations for all used rows. Note that the row letters skip the letters I, O, Q, S, X, and Z. If the exact rows are not known, then the AlphaDictNumbering class can be used instead to at least provide some type safety for the first 20 rows.

>>> class My4RowNumbering(AlphaDictNumberingBase):
...     A: dict[int, Pad]
...     B: dict[int, Pad]
...     C: dict[int, Pad]
...     D: dict[int, Pad]
class AlphaDictNumbering[source]#

Bases: AlphaDictNumberingBase

Assign numbers to pads using an alpha-numeric dictionary. The row is referred to by a letter as a member field, and the column is referred to by a number inside the dictionary at that field. The row letters skip the letters I, O, Q, S, X, and Z. Note that the type checker is only aware of the first 20 rows, so will not provide type safety beyond that. From row 20 each row will be referred to by two letters, row 20 will be referred to as “AA”, row 21 as “AB”, and so on.

Note

Only used rows will have their fields set, but please note that the type checker will not flag access to rows even though they may not be set at runtime, resulting in an attribute error. When in doubt, use inspect functions instead.

A: dict[int, Pad]#
B: dict[int, Pad]#
C: dict[int, Pad]#
D: dict[int, Pad]#
E: dict[int, Pad]#
F: dict[int, Pad]#
G: dict[int, Pad]#
H: dict[int, Pad]#
J: dict[int, Pad]#
K: dict[int, Pad]#
L: dict[int, Pad]#
M: dict[int, Pad]#
N: dict[int, Pad]#
P: dict[int, Pad]#
R: dict[int, Pad]#
T: dict[int, Pad]#
U: dict[int, Pad]#
V: dict[int, Pad]#
W: dict[int, Pad]#
Y: dict[int, Pad]#
class AlphaNumericNumberingBase[source]#

Bases: GridLayoutInterface

Base class to provide a BGA-style alpha-numeric numbering scheme. Pads are referred by a unique name consisting of the row letter and a number. It’s advisable to create a subclass with declarations for all used pads. Note that the row letters skip the letters I, O, Q, S, X, and Z. The column indicies start at 0 unless offset using, for example, A1, and are not zero-padded.

If pads are not known in advance, then introspection can be used to access pads with type safety, but without language server support. In this case it’s recommended to use something like the AlphaNumericNumbering class instead.

>>> class My9PadBGANumbering(AlphaNumericNumberingBase, A1):
...     A1: Pad
...     A2: Pad
...     A3: Pad
...     B1: Pad
...     B2: Pad
...     B3: Pad
...     C1: Pad
...     C2: Pad
...     C3: Pad
class LinearNumbering[source]#

Bases: GridLayoutInterface

Assign numbers to pads using a linear numbering scheme, starting at pad number 1, accessed through p[1]. Row and column indicies are ignored and pads are assigned in the generated order.

p: dict[int, Pad] = {}#
class GridLandpatternGenerator[source]#

Bases: LandpatternGenerator, GridLayoutInterface