loom_repetition_code.code_factory.repetition_code
Copyright 2024 Entropica Labs Pte Ltd
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- class loom_repetition_code.code_factory.repetition_code.RepetitionCode(*args, **kwargs)[source]
Bases:
BlockA sub-class of Block that represents a repetition code block. Contains methods to create a repetition code block.
- boundary_qubits(direction)[source]
Return the data qubits that are part of the specified boundary.
- Parameters:
direction (Direction | str) – Boundary (left or right) for which the data qubits should be returned. If a string is provided, it is converted to a Direction enum.
- Returns:
Data qubit in the specified boundary
- Return type:
tuple[int, int]
- property check_type: str
Extract the check type of the repetition code.
- Returns:
Check type of the repetition code, either “X” or “Z”
- Return type:
str
- classmethod create(d, check_type, lattice, unique_label=None, position=(0,), logical_x_operator=None, logical_z_operator=None, skip_validation=False)[source]
Create a Block object for a repetition code block. The repetition code is defined as a linear chain with open boundary conditions.
- Parameters:
d (int) – Code distance and size of the chain.
check_type (str) – Type of code stabilizers, either “X” (phase-flip) or “Z” (bit-flip).
lattice (Lattice) – Lattice on which the block is defined. The qubit indices depend on the type of lattice.
unique_label (str, optional) – Label for the block. It must be unique among all blocks in the initial CRD. If no label is provided, a unique label is generated automatically using the uuid module.
position (tuple[int, ...], optional) – Position of the top left corner of the block on the lattice, by default (0,).
logical_x_operator (PauliOperator | None, optional) – Logical X operator. For bit-flip code, if None is provided, by default the full chain of qubits is selected. For phase-flip code, if None is provided, by default the first qubit is selected.
logical_z_operator (PauliOperator | None, optional) – Logical Z operator. For phase-flip code, if None is provided, by default the full chain of qubits is selected. For bit-flip code, if None is provided, by default the first qubit is selected.
skip_validation (bool, optional) – Skip validation of the block object, by default False.
- Returns:
Block object for a repetition code chain
- Return type:
- get_shifted_equivalent_logical_operator(new_qubit)[source]
Get a shifted version of the single qubit logical operator and the stabilizers required to perform the shift.
- Parameters:
new_qubit (tuple[int, int]) – New qubit where the logical operator should be shifted.
- Returns:
Shifted logical operator and the stabilizers required to perform the shift.
- Return type:
tuple[PauliOperator, tuple[Stabilizer, …]]
- shift(position, new_label=None)[source]
Return a copy of the Block where all qubit coordinates are shifted by a given position.
- Parameters:
position (tuple[int, ...]) – Vector by which the block should be shifted
new_label (str | None, optional) – New label for the block. If None, the same label is used.
- Returns:
A new Block with the shifted qubit coordinates.
- Return type:
- stabilizer_to_circuit: dict[str, str] = FieldInfo(annotation=dict[str, str], required=False, default_factory=dict, validate_default=True)
- syndrome_circuits: tuple[SyndromeCircuit, ...] = FieldInfo(annotation=tuple[SyndromeCircuit, ...], required=False, default_factory=tuple, validate_default=True)
- unique_label: str = FieldInfo(annotation=str, required=False, default_factory=<lambda>)
- uuid: str = FieldInfo(annotation=str, required=False, default_factory=<lambda>, validate_default=True)