Skip to content

statements

from_positions

from_positions(
    x_positions: IList[float, Nx],
    y_positions: IList[float, Ny],
) -> Grid[Nx, Ny]
from_positions(
    x_positions: IList[float, Nx], y_positions: list[float]
) -> Grid[Nx, typing.Any]
from_positions(
    x_positions: list[float], y_positions: IList[float, Ny]
) -> Grid[typing.Any, Ny]
from_positions(
    x_positions: list[float], y_positions: list[float]
) -> Grid[typing.Any, typing.Any]
from_positions(x_positions, y_positions)

Construct a grid from the given x and y positions.

Parameters:

Name Type Description Default
x_positions IList[float] | list[float]

A list or ilist of floats representing the x-coordinates of grid points.

required
y_positions IList[float] | list[float]

A list or ilist of floats representing the y-coordinates of grid points.

required

Returns:

Name Type Description
Grid

a grid object

Source code in src/bloqade/geometry/dialects/grid/_interface.py
66
67
68
69
70
71
72
73
74
75
76
@_wraps(FromPositions)
def from_positions(x_positions, y_positions):
    """Construct a grid from the given x and y positions.

    Args:
        x_positions (IList[float] | list[float]): A list or ilist of floats representing the x-coordinates of grid points.
        y_positions (IList[float] | list[float]): A list or ilist of floats representing the y-coordinates of grid points.

    Returns:
        Grid: a grid object
    """

get

get(
    grid: Grid, idx: tuple[int, int]
) -> tuple[float, float]

Get the coordinate (x, y) of a grid at the given index.

Parameters:

Name Type Description Default
grid Grid

a grid object

required
idx tuple[int, int]

a tuple of (x, y) indices

required

Returns: tuple[float, float]: a tuple of (x, y) positions tuple[None, None]: if the grid has no initial x or y position

Source code in src/bloqade/geometry/dialects/grid/_interface.py
79
80
81
82
83
84
85
86
87
88
89
90
@_wraps(Get)
def get(grid: Grid, idx: tuple[int, int]) -> tuple[float, float]:
    """Get the coordinate (x, y) of a grid at the given index.

    Args:
        grid (Grid): a grid object
        idx (tuple[int, int]): a tuple of (x, y) indices
    Returns:
        tuple[float, float]: a tuple of (x, y) positions
        tuple[None, None]: if the grid has no initial x or y position
    """
    ...

get_xpos

get_xpos(grid: Grid[Nx, Any]) -> ilist.IList[float, Nx]

Get the x positions of a grid.

Parameters:

Name Type Description Default
grid Grid[Nx, Any]

a grid object

required

Returns: ilist.IList[float, typing.Any]: a list of x positions

Source code in src/bloqade/geometry/dialects/grid/_interface.py
 93
 94
 95
 96
 97
 98
 99
100
101
102
@_wraps(GetXPos)
def get_xpos(grid: Grid[Nx, typing.Any]) -> ilist.IList[float, Nx]:
    """Get the x positions of a grid.

    Args:
        grid: a grid object
    Returns:
        ilist.IList[float, typing.Any]: a list of x positions
    """
    ...

get_ypos

get_ypos(grid: Grid[Any, Ny]) -> ilist.IList[float, Ny]

Get the y positions of a grid.

Parameters:

Name Type Description Default
grid Grid[Any, Ny]

a grid object

required

Returns: ilist.IList[float, typing.Any]: a list of y positions

Source code in src/bloqade/geometry/dialects/grid/_interface.py
105
106
107
108
109
110
111
112
113
114
@_wraps(GetYPos)
def get_ypos(grid: Grid[typing.Any, Ny]) -> ilist.IList[float, Ny]:
    """Get the y positions of a grid.

    Args:
        grid: a grid object
    Returns:
        ilist.IList[float, typing.Any]: a list of y positions
    """
    ...

new

new(
    x_spacing: IList[float, Any] | list[float],
    y_spacing: IList[float, Any] | list[float],
    x_init: float,
    y_init: float,
) -> Grid[typing.Any, typing.Any]

Create a new grid with the given spacing and initial position.

Parameters:

Name Type Description Default
x_spacing IList[float] | list[float]

The spacing in the x direction.

required
y_spacing IList[float] | list[float]

The spacing in the y direction.

required
x_init float

The initial position in the x direction.

required
y_init float

The initial position in the y direction.

required

Returns:

Name Type Description
Grid Grid[Any, Any]

A new grid object.

Source code in src/bloqade/geometry/dialects/grid/_interface.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
@_wraps(New)
def new(
    x_spacing: ilist.IList[float, typing.Any] | list[float],
    y_spacing: ilist.IList[float, typing.Any] | list[float],
    x_init: float,
    y_init: float,
) -> Grid[typing.Any, typing.Any]:
    """
    Create a new grid with the given spacing and initial position.

    Args:
        x_spacing (IList[float] | list[float]): The spacing in the x direction.
        y_spacing (IList[float] | list[float]): The spacing in the y direction.
        x_init (float): The initial position in the x direction.
        y_init (float): The initial position in the y direction.

    Returns:
        Grid: A new grid object.
    """
    ...

positions

positions(
    grid: Grid[Any, Any],
) -> ilist.IList[tuple[float, float], typing.Any]

Get the positions of a grid as a list of (x, y) tuples.

Parameters:

Name Type Description Default
grid Grid

a grid object

required

Returns:

Type Description
IList[tuple[float, float], Any]

ilist.IList[tuple[float, float], typing.Any]: a list of (x, y) tuples representing the positions of the grid points

Source code in src/bloqade/geometry/dialects/grid/_interface.py
172
173
174
175
176
177
178
179
180
181
182
183
184
185
@_wraps(Positions)
def positions(
    grid: Grid[typing.Any, typing.Any],
) -> ilist.IList[tuple[float, float], typing.Any]:
    """Get the positions of a grid as a list of (x, y) tuples.

    Args:
        grid (Grid): a grid object

    Returns:
        ilist.IList[tuple[float, float], typing.Any]: a list of (x, y) tuples representing the positions of the grid points

    """
    ...

repeat

repeat(
    grid: Grid,
    x_times: int,
    y_times: int,
    x_spacing: float,
    y_spacing: float,
) -> Grid

Repeat a grid in the x and y directions.

Parameters:

Name Type Description Default
grid Grid

a grid object

required
x_times int

number of times to repeat in the x direction

required
y_times int

number of times to repeat in the y direction

required
x_spacing float

spacing in the x direction

required
y_spacing float

spacing in the y direction

required

Returns: Grid: a new grid object with the repeated pattern

Source code in src/bloqade/geometry/dialects/grid/_interface.py
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
@_wraps(Repeat)
def repeat(
    grid: Grid, x_times: int, y_times: int, x_spacing: float, y_spacing: float
) -> Grid:
    """Repeat a grid in the x and y directions.

    Args:
        grid (Grid): a grid object
        x_times (int): number of times to repeat in the x direction
        y_times (int): number of times to repeat in the y direction
        x_spacing (float): spacing in the x direction
        y_spacing (float): spacing in the y direction
    Returns:
        Grid: a new grid object with the repeated pattern
    """
    ...

scale

scale(
    grid: Grid[Nx, Ny], x_scale: float, y_scale: float
) -> Grid[Nx, Ny]

Scale a grid in the x and y directions.

Parameters:

Name Type Description Default
grid Grid

a grid object

required
x_scale float

scaling factor in the x direction

required
y_scale float

scaling factor in the y direction

required

Returns: Grid: a new grid object that has been scaled

Source code in src/bloqade/geometry/dialects/grid/_interface.py
206
207
208
209
210
211
212
213
214
215
216
217
@_wraps(Scale)
def scale(grid: Grid[Nx, Ny], x_scale: float, y_scale: float) -> Grid[Nx, Ny]:
    """Scale a grid in the x and y directions.

    Args:
        grid (Grid): a grid object
        x_scale (float): scaling factor in the x direction
        y_scale (float): scaling factor in the y direction
    Returns:
        Grid: a new grid object that has been scaled
    """
    ...

shape

shape(grid: Grid) -> tuple[int, int]

Get the shape of a grid.

Parameters:

Name Type Description Default
grid Grid

a grid object

required

Returns: tuple[int, int]: a tuple of (num_x, num_y)

Source code in src/bloqade/geometry/dialects/grid/_interface.py
234
235
236
237
238
239
240
241
242
243
@_wraps(Shape)
def shape(grid: Grid) -> tuple[int, int]:
    """Get the shape of a grid.

    Args:
        grid (Grid): a grid object
    Returns:
        tuple[int, int]: a tuple of (num_x, num_y)
    """
    ...

shift

shift(
    grid: Grid[Nx, Ny], x_shift: float, y_shift: float
) -> Grid[Nx, Ny]

Shift a grid in the x and y directions.

Parameters:

Name Type Description Default
grid Grid

a grid object

required
x_shift float

shift in the x direction

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/_interface.py
220
221
222
223
224
225
226
227
228
229
230
231
@_wraps(Shift)
def shift(grid: Grid[Nx, Ny], x_shift: float, y_shift: float) -> Grid[Nx, Ny]:
    """Shift a grid in the x and y directions.

    Args:
        grid (Grid): a grid object
        x_shift (float): shift in the x direction
        y_shift (float): shift in the y direction
    Returns:
        Grid: a new grid object that has been shifted
    """
    ...

sub_grid

sub_grid(
    grid: Grid,
    x_indices: IList[int, Nx],
    y_indices: IList[int, Ny],
) -> Grid[Nx, Ny]
sub_grid(
    grid: Grid,
    x_indices: IList[int, Nx],
    y_indices: list[int],
) -> Grid[Nx, typing.Any]
sub_grid(
    grid: Grid,
    x_indices: list[int],
    y_indices: IList[int, Ny],
) -> Grid[typing.Any, Ny]
sub_grid(
    grid: Grid, x_indices: list[int], y_indices: list[int]
) -> Grid[typing.Any, typing.Any]
sub_grid(grid, x_indices, y_indices)

Get a subgrid from the given grid.

Parameters:

Name Type Description Default
grid Grid

a grid object

required
x_indices

a list/ilist of x indices

required
y_indices

a list/ilist of y indices

required

Returns: Grid: a subgrid object

Source code in src/bloqade/geometry/dialects/grid/_interface.py
133
134
135
136
137
138
139
140
141
142
143
144
@_wraps(GetSubGrid)
def sub_grid(grid, x_indices, y_indices):
    """Get a subgrid from the given grid.

    Args:
        grid (Grid): a grid object
        x_indices: a list/ilist of x indices
        y_indices: a list/ilist of y indices
    Returns:
        Grid: a subgrid object
    """
    ...

x_bounds

x_bounds(grid: Grid[Any, Any]) -> tuple[float, float]

Get the x bounds of a grid.

Parameters:

Name Type Description Default
grid Grid

a grid object

required

Returns: tuple[float, float]: a tuple of (min_x, max_x)

Source code in src/bloqade/geometry/dialects/grid/_interface.py
147
148
149
150
151
152
153
154
155
156
@_wraps(GetXBounds)
def x_bounds(grid: Grid[typing.Any, typing.Any]) -> tuple[float, float]:
    """Get the x bounds of a grid.

    Args:
        grid (Grid): a grid object
    Returns:
        tuple[float, float]: a tuple of (min_x, max_x)
    """
    ...

y_bounds

y_bounds(grid: Grid[Any, Any]) -> tuple[float, float]

Get the y bounds of a grid.

Parameters:

Name Type Description Default
grid Grid

a grid object

required

Returns: tuple[float, float]: a tuple of (min_y, max_y) tuple[None, None]: if the grid has no initial y position

Source code in src/bloqade/geometry/dialects/grid/_interface.py
159
160
161
162
163
164
165
166
167
168
169
@_wraps(GetYBounds)
def y_bounds(grid: Grid[typing.Any, typing.Any]) -> tuple[float, float]:
    """Get the y bounds of a grid.

    Args:
        grid (Grid): a grid object
    Returns:
        tuple[float, float]: a tuple of (min_y, max_y)
        tuple[None, None]: if the grid has no initial y position
    """
    ...