Esempio n. 1
0
def make_kraus_instruction(mats, qubits):
    """Return a qobj instruction for a Kraus error.

    Args:
        mats (list[matrix]): A list of square or diagonal Kraus matrices.
        qubits (list[int]): The qubits the matrix is applied to.
    Returns:
        dict: The qobj instruction object.

    Raises:
        NoiseError: if the input is not a CPTP Kraus channel.
    """
    kraus = Kraus(mats)
    if not kraus.is_cptp() or kraus._input_dim != kraus._output_dim:
        raise NoiseError("Input Kraus matrices are not a CPTP channel.")
    if isinstance(qubits, int):
        qubits = [qubits]
    return [{"name": "kraus", "qubits": qubits, "params": kraus.data}]
Esempio n. 2
0
def make_kraus_instruction(mats, qubits):
    """Return a qobj instruction for a Kraus error.

    Args:
        mats (list[matrix]): A list of square or diagonal Kraus matrices.
        qubits (list[int]): The qubits the matrix is applied to.
    Returns:
        dict: The qobj instruction object.

    Raises:
        NoiseError: if the input is not a CPTP Kraus channel.
    """
    warnings.warn(
        'make_kraus_instruction has been deprecated as of qiskit-aer 0.10.0'
        ' and will be removed no earlier than 3 months from that release date.',
        DeprecationWarning, stacklevel=2)

    kraus = Kraus(mats)
    if not kraus.is_cptp() or kraus._input_dim != kraus._output_dim:
        raise NoiseError("Input Kraus matrices are not a CPTP channel.")
    if isinstance(qubits, int):
        qubits = [qubits]
    return [{"name": "kraus", "qubits": qubits, "params": kraus.data}]