qiskit-documentation/docs/api/qiskit/0.26/qiskit.pulse.Instruction.mdx

336 lines
14 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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: Instruction (v0.26)
description: API reference for qiskit.pulse.Instruction in qiskit v0.26
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.pulse.Instruction
---
<span id="qiskit-pulse-instruction" />
# qiskit.pulse.Instruction
<Class id="qiskit.pulse.Instruction" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.17/qiskit/pulse/instructions/instruction.py" signature="Instruction(operands, duration=None, channels=None, name=None)" modifiers="class">
The smallest schedulable unit: a single instruction. It has a fixed duration and specified channels.
Instruction initializer.
**Parameters**
* **operands** (`Tuple`) The argument list.
* **duration** (`Optional`\[`int`]) Deprecated.
* **channels** (`Optional`\[`Tuple`\[[`Channel`](qiskit.pulse.channels#channel "qiskit.pulse.channels.Channel")]]) Deprecated.
* **name** (`Optional`\[`str`]) Optional display name for this instruction.
**Raises**
* [**PulseError**](qiskit.pulse.PulseError "qiskit.pulse.PulseError") If duration is negative.
* [**PulseError**](qiskit.pulse.PulseError "qiskit.pulse.PulseError") If the input `channels` are not all of type `Channel`.
### \_\_init\_\_
<Function id="qiskit.pulse.Instruction.__init__" signature="__init__(operands, duration=None, channels=None, name=None)">
Instruction initializer.
**Parameters**
* **operands** (`Tuple`) The argument list.
* **duration** (`Optional`\[`int`]) Deprecated.
* **channels** (`Optional`\[`Tuple`\[[`Channel`](qiskit.pulse.channels#channel "qiskit.pulse.channels.Channel")]]) Deprecated.
* **name** (`Optional`\[`str`]) Optional display name for this instruction.
**Raises**
* [**PulseError**](qiskit.pulse.PulseError "qiskit.pulse.PulseError") If duration is negative.
* [**PulseError**](qiskit.pulse.PulseError "qiskit.pulse.PulseError") If the input `channels` are not all of type `Channel`.
</Function>
## Methods
| | |
| ---------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`__init__`](#qiskit.pulse.Instruction.__init__ "qiskit.pulse.Instruction.__init__")(operands\[, duration, channels, name]) | Instruction initializer. |
| [`append`](#qiskit.pulse.Instruction.append "qiskit.pulse.Instruction.append")(schedule\[, name]) | Return a new [`Schedule`](qiskit.pulse.Schedule "qiskit.pulse.Schedule") with `schedule` inserted at the maximum time over all channels shared between `self` and `schedule`. |
| [`assign_parameters`](#qiskit.pulse.Instruction.assign_parameters "qiskit.pulse.Instruction.assign_parameters")(value\_dict) | Modify and return self with parameters assigned according to the input. |
| [`ch_duration`](#qiskit.pulse.Instruction.ch_duration "qiskit.pulse.Instruction.ch_duration")(\*channels) | Return duration of the supplied channels in this Instruction. |
| [`ch_start_time`](#qiskit.pulse.Instruction.ch_start_time "qiskit.pulse.Instruction.ch_start_time")(\*channels) | Return minimum start time for supplied channels. |
| [`ch_stop_time`](#qiskit.pulse.Instruction.ch_stop_time "qiskit.pulse.Instruction.ch_stop_time")(\*channels) | Return maximum start time for supplied channels. |
| [`draw`](#qiskit.pulse.Instruction.draw "qiskit.pulse.Instruction.draw")(\[dt, style, filename, interp\_method, …]) | Plot the instruction. |
| [`flatten`](#qiskit.pulse.Instruction.flatten "qiskit.pulse.Instruction.flatten")() | Return itself as already single instruction. |
| [`insert`](#qiskit.pulse.Instruction.insert "qiskit.pulse.Instruction.insert")(start\_time, schedule\[, name]) | Return a new [`Schedule`](qiskit.pulse.Schedule "qiskit.pulse.Schedule") with `schedule` inserted within `self` at `start_time`. |
| [`is_parameterized`](#qiskit.pulse.Instruction.is_parameterized "qiskit.pulse.Instruction.is_parameterized")() | Return True iff the instruction is parameterized. |
| [`shift`](#qiskit.pulse.Instruction.shift "qiskit.pulse.Instruction.shift")(time\[, name]) | Return a new schedule shifted forward by time. |
## Attributes
| | |
| ------------------------------------------------------------------------------------------------ | ----------------------------------------------------- |
| [`channels`](#qiskit.pulse.Instruction.channels "qiskit.pulse.Instruction.channels") | Returns the channels that this schedule uses. |
| [`duration`](#qiskit.pulse.Instruction.duration "qiskit.pulse.Instruction.duration") | Duration of this instruction. |
| [`id`](#qiskit.pulse.Instruction.id "qiskit.pulse.Instruction.id") | Unique identifier for this instruction. |
| [`instructions`](#qiskit.pulse.Instruction.instructions "qiskit.pulse.Instruction.instructions") | Iterable for getting instructions from Schedule tree. |
| [`name`](#qiskit.pulse.Instruction.name "qiskit.pulse.Instruction.name") | Name of this instruction. |
| [`operands`](#qiskit.pulse.Instruction.operands "qiskit.pulse.Instruction.operands") | Return instruction operands. |
| [`parameters`](#qiskit.pulse.Instruction.parameters "qiskit.pulse.Instruction.parameters") | Parameters which determine the instruction behavior. |
| [`start_time`](#qiskit.pulse.Instruction.start_time "qiskit.pulse.Instruction.start_time") | Relative begin time of this instruction. |
| [`stop_time`](#qiskit.pulse.Instruction.stop_time "qiskit.pulse.Instruction.stop_time") | Relative end time of this instruction. |
### append
<Function id="qiskit.pulse.Instruction.append" signature="append(schedule, name=None)">
Return a new [`Schedule`](qiskit.pulse.Schedule "qiskit.pulse.Schedule") with `schedule` inserted at the maximum time over all channels shared between `self` and `schedule`.
**Parameters**
* **schedule** (*Union\['Schedule', 'Instruction']*) Schedule or instruction to be appended
* **name** (`Optional`\[`str`]) Name of the new schedule. Defaults to name of self
**Returns**
A new schedule with `schedule` a this instruction at t=0.
**Return type**
[Schedule](qiskit.pulse.Schedule "qiskit.pulse.Schedule")
</Function>
### assign\_parameters
<Function id="qiskit.pulse.Instruction.assign_parameters" signature="assign_parameters(value_dict)">
Modify and return self with parameters assigned according to the input.
**Parameters**
**value\_dict** (`Dict`\[`ParameterExpression`, `Union`\[`ParameterExpression`, `float`, `int`]]) A mapping from Parameters to either numeric values or another Parameter expression.
**Return type**
`Instruction`
**Returns**
Self with updated parameters.
</Function>
### ch\_duration
<Function id="qiskit.pulse.Instruction.ch_duration" signature="ch_duration(*channels)">
Return duration of the supplied channels in this Instruction.
**Parameters**
**\*channels** Supplied channels
**Return type**
`int`
</Function>
### ch\_start\_time
<Function id="qiskit.pulse.Instruction.ch_start_time" signature="ch_start_time(*channels)">
Return minimum start time for supplied channels.
**Parameters**
**\*channels** Supplied channels
**Return type**
`int`
</Function>
### ch\_stop\_time
<Function id="qiskit.pulse.Instruction.ch_stop_time" signature="ch_stop_time(*channels)">
Return maximum start time for supplied channels.
**Parameters**
**\*channels** Supplied channels
**Return type**
`int`
</Function>
### channels
<Function id="qiskit.pulse.Instruction.channels" signature="channels" modifiers="abstract property">
Returns the channels that this schedule uses.
**Return type**
`Tuple`\[[`Channel`](qiskit.pulse.channels#channel "qiskit.pulse.channels.Channel")]
</Function>
### draw
<Function id="qiskit.pulse.Instruction.draw" signature="draw(dt=1, style=None, filename=None, interp_method=None, scale=1, plot_all=False, plot_range=None, interactive=False, table=True, label=False, framechange=True, channels=None)">
Plot the instruction.
**Parameters**
* **dt** (`float`) Time interval of samples
* **style** (*Optional\[SchedStyle]*) A style sheet to configure plot appearance
* **filename** (`Optional`\[`str`]) Name required to save pulse image
* **interp\_method** (`Optional`\[`Callable`]) A function for interpolation
* **scale** (`float`) Relative visual scaling of waveform amplitudes
* **plot\_all** (`bool`) Plot empty channels
* **plot\_range** (`Optional`\[`Tuple`\[`float`]]) A tuple of time range to plot
* **interactive** (`bool`) When set true show the circuit in a new window (this depends on the matplotlib backend being used supporting this)
* **table** (`bool`) Draw event table for supported instructions
* **label** (`bool`) Label individual instructions
* **framechange** (`bool`) Add framechange indicators
* **channels** (`Optional`\[`List`\[[`Channel`](qiskit.pulse.channels#channel "qiskit.pulse.channels.Channel")]]) A list of channel names to plot
**Returns**
A matplotlib figure object of the pulse schedule
**Return type**
matplotlib.figure
</Function>
### duration
<Attribute id="qiskit.pulse.Instruction.duration">
Duration of this instruction.
**Return type**
`int`
</Attribute>
### flatten
<Function id="qiskit.pulse.Instruction.flatten" signature="flatten()">
Return itself as already single instruction.
**Return type**
`Instruction`
</Function>
### id
<Attribute id="qiskit.pulse.Instruction.id">
Unique identifier for this instruction.
**Return type**
`int`
</Attribute>
### insert
<Function id="qiskit.pulse.Instruction.insert" signature="insert(start_time, schedule, name=None)">
Return a new [`Schedule`](qiskit.pulse.Schedule "qiskit.pulse.Schedule") with `schedule` inserted within `self` at `start_time`.
**Parameters**
* **start\_time** (`int`) Time to insert the schedule schedule
* **schedule** (*Union\['Schedule', 'Instruction']*) Schedule or instruction to insert
* **name** (`Optional`\[`str`]) Name of the new schedule. Defaults to name of self
**Returns**
A new schedule with `schedule` inserted with this instruction at t=0.
**Return type**
[Schedule](qiskit.pulse.Schedule "qiskit.pulse.Schedule")
</Function>
### instructions
<Attribute id="qiskit.pulse.Instruction.instructions">
Iterable for getting instructions from Schedule tree.
**Return type**
`Tuple`\[`Tuple`\[`int`, `Instruction`]]
</Attribute>
### is\_parameterized
<Function id="qiskit.pulse.Instruction.is_parameterized" signature="is_parameterized()">
Return True iff the instruction is parameterized.
**Return type**
`bool`
</Function>
### name
<Attribute id="qiskit.pulse.Instruction.name">
Name of this instruction.
**Return type**
`str`
</Attribute>
### operands
<Attribute id="qiskit.pulse.Instruction.operands">
Return instruction operands.
**Return type**
`Tuple`
</Attribute>
### parameters
<Attribute id="qiskit.pulse.Instruction.parameters">
Parameters which determine the instruction behavior.
**Return type**
`Set`
</Attribute>
### shift
<Function id="qiskit.pulse.Instruction.shift" signature="shift(time, name=None)">
Return a new schedule shifted forward by time.
**Parameters**
* **time** (`int`) Time to shift by
* **name** (`Optional`\[`str`]) Name of the new schedule. Defaults to name of self
**Returns**
The shifted schedule.
**Return type**
[Schedule](qiskit.pulse.Schedule "qiskit.pulse.Schedule")
</Function>
### start\_time
<Attribute id="qiskit.pulse.Instruction.start_time">
Relative begin time of this instruction.
**Return type**
`int`
</Attribute>
### stop\_time
<Attribute id="qiskit.pulse.Instruction.stop_time">
Relative end time of this instruction.
**Return type**
`int`
</Attribute>
</Class>