types
Grid dataclass
Grid(
x_spacing: tuple[float, ...],
y_spacing: tuple[float, ...],
x_init: float | None,
y_init: float | None,
)
Bases: Data['Grid'], Generic[NumX, NumY]
flowchart TD
bloqade.geometry.dialects.grid.types.Grid[Grid]
click bloqade.geometry.dialects.grid.types.Grid href "" "bloqade.geometry.dialects.grid.types.Grid"
height cached property
height
Height of the grid, which is the sum of y_spacing.
positions cached property
positions: IList[tuple[float, float], Any]
All positions in the grid as a list of tuples (x, y) in lexicographic order.
shape cached property
shape: tuple[int, int]
Shape of the grid, which is (num_x, num_y).
Note
if x_init or y_init is None, num_x or num_y will be 0 respectively.
width cached property
width
Width of the grid, which is the sum of x_spacing.
x_init instance-attribute
x_init: float | None
The initial x position of the grid, or None if not set.
x_positions cached property
x_positions: tuple[float, ...]
X positions of the grid.
Note
If x_init is None, returns an empty tuple.
x_spacing instance-attribute
x_spacing: tuple[float, ...]
A tuple of x spacings between grid points.
y_init instance-attribute
y_init: float | None
The initial y position of the grid, or None if not set.
y_positions cached property
y_positions: tuple[float, ...]
Y positions of the grid.
Note
If y_init is None, returns an empty tuple.
y_spacing instance-attribute
y_spacing: tuple[float, ...]
A tuple of y spacings between grid points.
col_y_pos
col_y_pos(column_index: int) -> ilist.IList[float, NumY]
Get the y positions of a specific column in the grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column_index | int | The index of the column. | required |
Returns:
| Type | Description |
|---|---|
IList[float, NumY] | IList[float, NumY]: The y positions of the specified column. |
Source code in src/bloqade/geometry/dialects/grid/types.py
503 504 505 506 507 508 509 510 511 512 | |
from_positions classmethod
from_positions(
x_positions: Sequence[float],
y_positions: Sequence[float],
)
Create a grid from sequence of x and y positions.
Args:
x_positions (Sequence[float]): The x positions.
y_positions (Sequence[float]): The y positions.
Returns:
| Name | Type | Description |
|---|---|---|
Grid | A grid object with the specified x and y positions. |
Source code in src/bloqade/geometry/dialects/grid/types.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
get
get(idx: tuple[int, int]) -> tuple[float, float]
Get the (x, y) position at the specified grid index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx | tuple[int, int] | The (x, y) index in the grid. | required |
Returns:
| Type | Description |
|---|---|
tuple[float, float] | tuple[float, float]: The (x, y) position in the grid. |
Source code in src/bloqade/geometry/dialects/grid/types.py
200 201 202 203 204 205 206 207 208 209 | |
get_view
get_view(
x_indices: IList[int, Nx], y_indices: IList[int, Ny]
) -> Grid[Nx, Ny]
get_view(
x_indices: Sequence[int], y_indices: IList[int, Ny]
) -> Grid[Any, Ny]
get_view(
x_indices: IList[int, Nx], y_indices: Sequence[int]
) -> Grid[Nx, Any]
get_view(
x_indices: Sequence[int], y_indices: Sequence[int]
) -> Grid[Any, Any]
get_view(x_indices, y_indices) -> Grid
Get a sub-grid view based on the specified x and y indices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_indices | Sequence[int] | The x indices to include in the sub-grid. | required |
y_indices | Sequence[int] | The y indices to include in the sub-grid. | required |
Returns:
| Name | Type | Description |
|---|---|---|
Grid | Grid | The sub-grid view. |
Source code in src/bloqade/geometry/dialects/grid/types.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
is_equal
is_equal(other: Any) -> bool
Check if two grid geometry are equal.
Source code in src/bloqade/geometry/dialects/grid/types.py
68 69 70 71 72 73 74 75 76 77 | |
repeat
repeat(
x_times: int, y_times: int, x_gap: float, y_gap: float
) -> Grid[NumX, NumY]
Repeat the grid in both x and y directions with specified gaps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_times | int | The number of times to repeat the grid in the x direction. | required |
y_times | int | The number of times to repeat the grid in the y direction. | required |
x_gap | float | The gap between repeated grids in the x direction. | required |
y_gap | float | The gap between repeated grids in the y direction. | required |
Returns:
| Type | Description |
|---|---|
Grid[NumX, NumY] | Grid[NumX, NumY]: A new grid with the specified repetitions and gaps. |
Source code in src/bloqade/geometry/dialects/grid/types.py
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | |
row_x_pos
row_x_pos(row_index: int) -> ilist.IList[float, NumX]
Get the x positions of a specific row in the grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row_index | int | The index of the row. | required |
Returns:
| Type | Description |
|---|---|
IList[float, NumX] | IList[float, NumX]: The x positions of the specified row. |
Source code in src/bloqade/geometry/dialects/grid/types.py
492 493 494 495 496 497 498 499 500 501 | |
scale
scale(x_scale: float, y_scale: float) -> Grid[NumX, NumY]
Scale the grid spacings by the specified x and y factors with fixed x and y initial positions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_scale | float | The scaling factor for the x spacings. | required |
y_scale | float | The scaling factor for the y spacings. | required |
Returns:
| Type | Description |
|---|---|
Grid[NumX, NumY] | Grid[NumX, NumY]: A new grid with scaled x and y spacings |
Source code in src/bloqade/geometry/dialects/grid/types.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
set_init
set_init(
x_init: float | None, y_init: float | None
) -> Grid[NumX, NumY]
Set the initial positions of the grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_init | float | None | The new initial x position. If None, the grid will not have an initial x position. | required |
y_init | float | None | The new initial y position. If None, the grid will not have an initial y position. | required |
Returns:
| Type | Description |
|---|---|
Grid[NumX, NumY] | Grid[NumX, NumY]: A new grid with the specified initial positions. |
Source code in src/bloqade/geometry/dialects/grid/types.py
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
shift
shift(x_shift: float, y_shift: float) -> Grid[NumX, NumY]
Shift the grid by the specified x and y amounts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_shift | float | The amount to shift the grid in the x direction. | required |
y_shift | float | The amount to shift the grid in the y direction. | required |
Returns:
| Type | Description |
|---|---|
Grid[NumX, NumY] | Grid[NumX, NumY]: A new grid with the specified shifts applied to the initial positions. |
Source code in src/bloqade/geometry/dialects/grid/types.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
shift_subgrid_x
shift_subgrid_x(
x_indices: IList[int, Nx] | slice, x_shift: float
) -> Grid[NumX, NumY]
Shift a sub grid of grid in the x directions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid | Grid | a grid object | required |
x_indices | float | a list/ilist of x indices to shift | required |
x_shift | float | shift in the x direction | required |
Returns: Grid: a new grid object that has been shifted
Source code in src/bloqade/geometry/dialects/grid/types.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
shift_subgrid_y
shift_subgrid_y(
y_indices: IList[int, Ny] | slice, y_shift: float
) -> Grid[NumX, NumY]
Shift a sub grid of grid in the y directions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid | Grid | a grid object | required |
y_indices | float | a list/ilist of y indices to shift | required |
y_shift | float | shift in the y direction | required |
Returns: Grid: a new grid object that has been shifted
Source code in src/bloqade/geometry/dialects/grid/types.py
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | |
x_bounds
x_bounds()
X bounds of the grid, which is (x_init, x_init + width).
Raises:
| Type | Description |
|---|---|
ValueError | If x_init is None, cannot compute bounds. |
Source code in src/bloqade/geometry/dialects/grid/types.py
136 137 138 139 140 141 142 143 144 145 146 | |
y_bounds
y_bounds()
Y bounds of the grid, which is (y_init, y_init + height).
Raises:
| Type | Description |
|---|---|
ValueError | If y_init is None, cannot compute bounds. |
Source code in src/bloqade/geometry/dialects/grid/types.py
148 149 150 151 152 153 154 155 156 157 158 | |
SubGrid dataclass
SubGrid(
x_spacing: tuple[float, ...],
y_spacing: tuple[float, ...],
x_init: float | None,
y_init: float | None,
parent: Grid[Any, Any],
x_indices: IList[int, NumX],
y_indices: IList[int, NumY],
)
Bases: Grid[NumX, NumY]
flowchart TD
bloqade.geometry.dialects.grid.types.SubGrid[SubGrid]
bloqade.geometry.dialects.grid.types.Grid[Grid]
bloqade.geometry.dialects.grid.types.Grid --> bloqade.geometry.dialects.grid.types.SubGrid
click bloqade.geometry.dialects.grid.types.SubGrid href "" "bloqade.geometry.dialects.grid.types.SubGrid"
click bloqade.geometry.dialects.grid.types.Grid href "" "bloqade.geometry.dialects.grid.types.Grid"
A sub-grid view of a parent grid with specified x and y indices.
For API documentation see the Grid class.
x_init class-attribute instance-attribute
x_init: float | None = field(init=False)
The initial x position of the grid, or None if not set.
x_spacing class-attribute instance-attribute
x_spacing: tuple[float, ...] = field(init=False)
A tuple of x spacings between grid points.
y_init class-attribute instance-attribute
y_init: float | None = field(init=False)
The initial y position of the grid, or None if not set.
y_spacing class-attribute instance-attribute
y_spacing: tuple[float, ...] = field(init=False)
A tuple of y spacings between grid points.
get_view
get_view(x_indices, y_indices)
Get a sub-grid view based on the specified x and y indices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_indices | Sequence[int] | The x indices to include in the sub-grid. | required |
y_indices | Sequence[int] | The y indices to include in the sub-grid. | required |
Returns:
| Name | Type | Description |
|---|---|---|
Grid | Grid | The sub-grid view. |
Source code in src/bloqade/geometry/dialects/grid/types.py
597 598 599 600 601 | |