# This code is part of Qiskit.
#
# (C) Copyright IBM 2021, 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
"""
Correlated readout error calibration experiment class.
"""
from typing import Iterable, List, Optional
from qiskit import QuantumCircuit
from qiskit.providers.backend import BackendV2, Backend
from qiskit.exceptions import QiskitError
from qiskit_experiments.framework import BaseExperiment
from qiskit_experiments.library.characterization.analysis.correlated_readout_error_analysis import (
CorrelatedReadoutErrorAnalysis,
)
def calibration_circuit(num_qubits: int, state_label: str) -> QuantumCircuit:
"""Return a calibration circuit.
This is an N-qubit circuit where N is the length of the label.
The circuit consists of X-gates on qubits with label bits equal to 1,
and measurements of all qubits.
"""
circ = QuantumCircuit(num_qubits, name="meas_mit_cal_" + state_label)
for i, val in enumerate(reversed(state_label)):
if val == "1":
circ.x(i)
circ.measure_all()
circ.metadata = {"state_label": state_label}
return circ