qiskit-documentation/docs/api/qiskit/dev/qiskit.qobj.QasmQobjInstruc...

72 lines
4.8 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: QasmQobjInstruction
description: API reference for qiskit.qobj.QasmQobjInstruction
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.qobj.QasmQobjInstruction
---
# QasmQobjInstruction
<Class id="qiskit.qobj.QasmQobjInstruction" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/main/qiskit/qobj/qasm_qobj.py#L24-L202" signature="qiskit.qobj.QasmQobjInstruction(name, params=None, qubits=None, register=None, memory=None, condition=None, conditional=None, label=None, mask=None, relation=None, val=None, snapshot_type=None)" modifiers="class">
Bases: [`object`](https://docs.python.org/3/library/functions.html#object "(in Python v3.12)")
A class representing a single instruction in an QasmQobj Experiment.
Instantiate a new QasmQobjInstruction object.
<Admonition title="Deprecated since version 1.2" type="danger">
The class `qiskit.qobj.qasm_qobj.QasmQobjInstruction` is deprecated as of qiskit 1.2. It will be removed in the 2.0 release. The Qobj class and related functionality are part of the deprecated BackendV1 workflow, and no longer necessary for BackendV2. If a user workflow requires Qobj it likely relies on deprecated functionality and should be updated to use BackendV2.
</Admonition>
**Parameters**
* **name** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.12)")) The name of the instruction
* **params** ([*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.12)")) The list of parameters for the gate
* **qubits** ([*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.12)")) A list of `int` representing the qubits the instruction operates on
* **register** ([*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.12)")) If a `measure` instruction this is a list of `int` containing the list of register slots in which to store the measurement results (must be the same length as qubits). If a `bfunc` instruction this is a single `int` of the register slot in which to store the result.
* **memory** ([*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.12)")) If a `measure` instruction this is a list of `int` containing the list of memory slots to store the measurement results in (must be the same length as qubits). If a `bfunc` instruction this is a single `int` of the memory slot to store the boolean function result in.
* **condition** ([*tuple*](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.12)")) A tuple of the form `(int, int)` where the first `int` is the control register and the second `int` is the control value if the gate has a condition.
* **conditional** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.12)")) The register index of the condition
* **label** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.12)")) An optional label assigned to the instruction
* **mask** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.12)")) For a `bfunc` instruction the hex value which is applied as an `AND` to the register bits.
* **relation** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.12)")) Relational operator for comparing the masked register to the `val` kwarg. Can be either `==` (equals) or `!=` (not equals).
* **val** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.12)")) Value to which to compare the masked register. In other words, the output of the function is `(register AND mask)`
* **snapshot\_type** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.12)")) For snapshot instructions the type of snapshot to use
## Methods
### from\_dict
<Function id="qiskit.qobj.QasmQobjInstruction.from_dict" github="https://github.com/Qiskit/qiskit/tree/main/qiskit/qobj/qasm_qobj.py#L185-L196" signature="from_dict(data)" modifiers="classmethod">
Create a new QasmQobjInstruction object from a dictionary.
**Parameters**
**data** ([*dict*](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.12)")) A dictionary for the experiment config
**Returns**
The object from the input dictionary.
**Return type**
[QasmQobjInstruction](#qiskit.qobj.QasmQobjInstruction "qiskit.qobj.QasmQobjInstruction")
</Function>
### to\_dict
<Function id="qiskit.qobj.QasmQobjInstruction.to_dict" github="https://github.com/Qiskit/qiskit/tree/main/qiskit/qobj/qasm_qobj.py#L106-L140" signature="to_dict()">
Return a dictionary format representation of the Instruction.
**Returns**
The dictionary form of the QasmQobjInstruction.
**Return type**
[dict](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.12)")
</Function>
</Class>