Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasberent committed Jun 3, 2024
1 parent 1fa089d commit 7d645ff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This script is used to run the color code phenomenological noise simulation.
""" This script is used to run the color code phenomenological noise simulation."""
from __future__ import annotations

import matplotlib.pyplot as plt
Expand Down
1 change: 1 addition & 0 deletions src/mqt/qecc/cc_decoder/stim_interface/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
""" init py file for stim_interface module """
16 changes: 9 additions & 7 deletions src/mqt/qecc/cc_decoder/stim_interface/color_code_stim.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Generate stim circuit for the 2D color code
"""Generate stim circuit for the 2D color code"""
from __future__ import annotations

import itertools as it
from typing import Any

import stim
import itertools as it
import numpy as np
import stim


def neighbors(perm: np.NDArray[int]) -> list[np.NDArray[int]]:
""" Return the neighbors of a lattice point in the 2D color code."""
node_sw = (perm[0] + 1, perm[1], perm[2] - 1)
node_se = (perm[0], perm[1] + 1, perm[2] - 1)
node_e = (perm[0] - 1, perm[1] + 1, perm[2])
Expand All @@ -19,6 +19,7 @@ def neighbors(perm: np.NDArray[int]) -> list[np.NDArray[int]]:


def gen_pcm_and_logical(distance: int) -> tuple[np.NDArray[bool], set[int]]:
"""Generate the parity check matrix and logical operator for the 2D color code."""
lattice_points_to_qubit_index, ancilla_qubit_to_lattice_points = {}, {}
qubit_count, ancilla_qubit_count = 0, 0
logical_operator = set()
Expand Down Expand Up @@ -46,6 +47,7 @@ def gen_pcm_and_logical(distance: int) -> tuple[np.NDArray[bool], set[int]]:


def add_checks_one_round(pcm: np.NDArray[int], circuit: Any, detectors: bool, error_probability: float) -> Any:
""" Add one round of checks to the circuit."""
for check in pcm:
if error_probability == 0:
mpp_X_instruction = "MPP "
Expand All @@ -68,9 +70,9 @@ def add_checks_one_round(pcm: np.NDArray[int], circuit: Any, detectors: bool, er
return circuit


def gen_stim_circuit_memory_experiment(
pcm: np.NDArray[int], logical_operator: np.NDArray[int], distance: int, error_probability: float
) -> Any:
def gen_stim_circuit_memory_experiment(pcm: np.NDArray[int], logical_operator: np.NDArray[int],
distance: int, error_probability: float) -> Any:
"""Generate a stim circuit for a memory experiment on the 2D color code."""
data_qubits = range(len(pcm[0]))
circuit = stim.Circuit()
circuit.append("R", data_qubits)
Expand Down

0 comments on commit 7d645ff

Please sign in to comment.