Skip to content

Encoding

Encoder dataclass

Encoder()

Bases: Data

Base class of all encodable entities.

encode abstractmethod

encode() -> int

Return the bit-packed encoded address as an integer.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/encoding.py
29
30
31
32
@abc.abstractmethod
def encode(self) -> int:
    """Return the bit-packed encoded address as an integer."""
    ...

LaneAddress

LaneAddress(
    move_type: MoveType,
    word_id: int,
    site_id: int,
    bus_id: int,
    direction: Direction = Direction.FORWARD,
)

Bases: Encoder

Address identifying a transport lane.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/encoding.py
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
def __init__(
    self,
    move_type: MoveType,
    word_id: int,
    site_id: int,
    bus_id: int,
    direction: Direction = Direction.FORWARD,
):
    self._inner = _RustLaneAddress(
        move_type,
        word_id,
        site_id,
        bus_id,
        direction,
    )
    self.__post_init__()

encode

encode() -> int

Return the bit-packed encoded address as an integer.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/encoding.py
170
171
def encode(self) -> int:
    return self._inner.encode()

replace

replace(
    *,
    move_type: MoveType | None = None,
    word_id: int | None = None,
    site_id: int | None = None,
    bus_id: int | None = None,
    direction: Direction | None = None
) -> Self

Return a copy, optionally replacing fields.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/encoding.py
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
def replace(
    self,
    *,
    move_type: MoveType | None = None,
    word_id: int | None = None,
    site_id: int | None = None,
    bus_id: int | None = None,
    direction: Direction | None = None,
) -> Self:
    """Return a copy, optionally replacing fields."""
    return LaneAddress(  # type: ignore[return-value]
        move_type if move_type is not None else self.move_type,
        word_id if word_id is not None else self.word_id,
        site_id if site_id is not None else self.site_id,
        bus_id if bus_id is not None else self.bus_id,
        direction if direction is not None else self.direction,
    )

src_site

src_site() -> LocationAddress

Get the source site as a LocationAddress.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/encoding.py
173
174
175
def src_site(self) -> LocationAddress:
    """Get the source site as a LocationAddress."""
    return LocationAddress(self.word_id, self.site_id)

LocationAddress

LocationAddress(word_id: int, site_id: int)

Bases: Encoder

Address identifying a physical atom location (word + site).

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/encoding.py
79
80
81
def __init__(self, word_id: int, site_id: int):
    self._inner = _RustLocationAddress(word_id, site_id)
    self.__post_init__()

encode

encode() -> int

Return the bit-packed encoded address as an integer.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/encoding.py
91
92
def encode(self) -> int:
    return self._inner.encode()

replace

replace(
    *,
    word_id: int | None = None,
    site_id: int | None = None
) -> Self

Return a copy, optionally replacing fields.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/encoding.py
107
108
109
110
111
112
113
114
115
116
117
def replace(
    self,
    *,
    word_id: int | None = None,
    site_id: int | None = None,
) -> Self:
    """Return a copy, optionally replacing fields."""
    return LocationAddress(  # type: ignore[return-value]
        word_id if word_id is not None else self.word_id,
        site_id if site_id is not None else self.site_id,
    )

SiteLaneAddress

SiteLaneAddress(
    word_id: int,
    site_id: int,
    bus_id: int,
    direction: Direction = Direction.FORWARD,
)

Bases: LaneAddress

LaneAddress with move_type fixed to MoveType.SITE.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/encoding.py
207
208
209
210
211
212
213
214
def __init__(
    self,
    word_id: int,
    site_id: int,
    bus_id: int,
    direction: Direction = Direction.FORWARD,
):
    super().__init__(MoveType.SITE, word_id, site_id, bus_id, direction)

WordLaneAddress

WordLaneAddress(
    word_id: int,
    site_id: int,
    bus_id: int,
    direction: Direction = Direction.FORWARD,
)

Bases: LaneAddress

LaneAddress with move_type fixed to MoveType.WORD.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/encoding.py
220
221
222
223
224
225
226
227
def __init__(
    self,
    word_id: int,
    site_id: int,
    bus_id: int,
    direction: Direction = Direction.FORWARD,
):
    super().__init__(MoveType.WORD, word_id, site_id, bus_id, direction)

ZoneAddress

ZoneAddress(zone_id: int)

Bases: Encoder

Address identifying a zone in the architecture.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/encoding.py
49
50
51
def __init__(self, zone_id: int):
    self._inner = _RustZoneAddress(zone_id)
    self.__post_init__()

encode

encode() -> int

Return the bit-packed encoded address as an integer.

Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/layout/encoding.py
57
58
def encode(self) -> int:
    return self._inner.encode()