grid_planner module#

class GridPlanner[source]#

Grid Planner Class

This base class provides an interface for determining which pads in a grid are active. Each subclass defines a ‘pattern’ of grid locations which are inactive or active. These can be composed together to create more complex grid patterns.

is_active(pos, num_rows, num_cols)[source]#

Determine if a pad is active based on the row and column.

Parameters:
  • pos (GridPosition) – The grid location to check.

  • num_rows (int) – The total number of rows in the grid.

  • num_cols (int) – The total number of columns in the grid.

Return type:

bool | None

Returns:

True if the pad is active, False if the pad is inactive. Returns None if this planner does not specify whether this pad is active or inactive (the decision is deferred to the next planner in the composition). If all planners return None for a pad, the pad is considered active by default.

num_active(num_rows, num_cols)[source]#

Convenience helper function to determine the number of active pads in the grid.

Return type:

int

Parameters:
  • num_rows (int)

  • num_cols (int)

class GridPlannerMixin[source]#

Bases: GridLayoutInterface

grid_planner(grid_planner)[source]#
Return type:

Self

Parameters:

grid_planner (GridPlanner | Callable[[GridPosition, int, int], bool])

class CompositeGridPlanner(*planners)[source]#

Bases: GridPlanner

Composite Grid Planner

This planner is a composite of other planners. For a given pad, the first planner that returns a non-None result is used. If all planners return None then None is returned. This allows more complex grid patterns to be created by composing multiple planners together.

Parameters:

planners (GridPlanner)

is_active(pos, num_rows, num_cols)[source]#

Determine if a pad is active based on the row and column.

Parameters:
  • pos (GridPosition) – The grid location to check.

  • num_rows (int) – The total number of rows in the grid.

  • num_cols (int) – The total number of columns in the grid.

Return type:

bool | None

Returns:

True if the pad is active, False if the pad is inactive. Returns None if this planner does not specify whether this pad is active or inactive (the decision is deferred to the next planner in the composition). If all planners return None for a pad, the pad is considered active by default.

class StaggeredGridPlanner(*, top_left_active=True)[source]#

Bases: GridPlanner

Staggered Grid Planner

This planner creates a grid where every other pad is inactive. The parity can be flipped by changing the top_left_active parameter.

Parameters:

top_left_active (bool)

is_active(pos, num_rows, num_cols)[source]#

Determine if a pad is active based on the row and column.

Parameters:
  • pos (GridPosition) – The grid location to check.

  • num_rows (int) – The total number of rows in the grid.

  • num_cols (int) – The total number of columns in the grid.

Return type:

bool | None

Returns:

True if the pad is active, False if the pad is inactive. Returns None if this planner does not specify whether this pad is active or inactive (the decision is deferred to the next planner in the composition). If all planners return None for a pad, the pad is considered active by default.

class PerimeterGridPlanner(perimeter_width)[source]#

Bases: GridPlanner

Perimeter Grid Planner

This planner creates a grid where only the pads on the perimeter are active. The width of the perimeter can be controlled by the perimeter_width parameter.

Parameters:

perimeter_width (int)

is_active(pos, num_rows, num_cols)[source]#

Determine if a pad is active based on the row and column.

Parameters:
  • pos (GridPosition) – The grid location to check.

  • num_rows (int) – The total number of rows in the grid.

  • num_cols (int) – The total number of columns in the grid.

Return type:

bool

Returns:

True if the pad is active, False if the pad is inactive. Returns None if this planner does not specify whether this pad is active or inactive (the decision is deferred to the next planner in the composition). If all planners return None for a pad, the pad is considered active by default.

class IslandGridPlanner(row_start, row_end, col_start, col_end, *, active=False)[source]#

Bases: GridPlanner

Island Grid Planner

This planner creates a rectangular region of pads that are either active or inactive. The indices are one-indexed and inclusive (both start and end indices are included). Rows go from top to bottom, columns from left to right. Negative indices are allowed, and indicate counting from the other side (i.e. -1 is the bottom row or rightmost column). 0 is not a valid index. The planner returns None for pads that are not in the island.

Parameters:
is_active(pos, num_rows, num_cols)[source]#

Determine if a pad is active based on the row and column.

Parameters:
  • pos (GridPosition) – The grid location to check.

  • num_rows (int) – The total number of rows in the grid.

  • num_cols (int) – The total number of columns in the grid.

Return type:

bool | None

Returns:

True if the pad is active, False if the pad is inactive. Returns None if this planner does not specify whether this pad is active or inactive (the decision is deferred to the next planner in the composition). If all planners return None for a pad, the pad is considered active by default.

InactiveIslandGridPlanner(row_start, row_end, col_start, col_end)[source]#

Create an inactive island grid planner

Parameters:
  • row_start (int) – starting row of the island, 1-indexed and inclusive.

  • row_end (int) – ending row of the island, 1-indexed and inclusive.

  • col_start (int) – starting column of the island, 1-indexed and inclusive.

  • col_end (int) – ending column of the island, 1-indexed and inclusive.

Return type:

IslandGridPlanner

Returns:

An inactive island grid planner

ActiveIslandGridPlanner(row_start, row_end, col_start, col_end)[source]#

Create an active island grid planner

Parameters:
  • row_start (int) – starting row of the island, 1-indexed and inclusive.

  • row_end (int) – ending row of the island, 1-indexed and inclusive.

  • col_start (int) – starting column of the island, 1-indexed and inclusive.

  • col_end (int) – ending column of the island, 1-indexed and inclusive.

Return type:

IslandGridPlanner

Returns:

An active island grid planner

class CornerCutGridPlanner(corner_width)[source]#

Bases: GridPlanner

Corner Cut Grid Planner

This planner creates a grid where the pads in the triangles at the corners of the grid are inactive. The width (the “legs” of the right triangle) of the triangles is controlled by the corner_width parameter.

Parameters:

corner_width (int)

is_active(pos, num_rows, num_cols)[source]#

Determine if a pad is active based on the row and column.

Parameters:
  • pos (GridPosition) – The grid location to check.

  • num_rows (int) – The total number of rows in the grid.

  • num_cols (int) – The total number of columns in the grid.

Return type:

bool | None

Returns:

True if the pad is active, False if the pad is inactive. Returns None if this planner does not specify whether this pad is active or inactive (the decision is deferred to the next planner in the composition). If all planners return None for a pad, the pad is considered active by default.