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:
- 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 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:
GridPlannerComposite 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:
- 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:
GridPlannerStaggered Grid Planner
This planner creates a grid where every other pad is inactive. The parity can be flipped by changing the
top_left_activeparameter.- 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:
- 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:
GridPlannerPerimeter 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_widthparameter.- 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:
- 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:
GridPlannerIsland 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
Nonefor pads that are not in the island.- 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:
- 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:
- Return type:
- Returns:
An inactive island grid planner
- ActiveIslandGridPlanner(row_start, row_end, col_start, col_end)[source]#
Create an active island grid planner
- Parameters:
- Return type:
- Returns:
An active island grid planner
- class CornerCutGridPlanner(corner_width)[source]#
Bases:
GridPlannerCorner 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_widthparameter.- 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:
- 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.