250 lines
6.8 KiB
Plaintext
250 lines
6.8 KiB
Plaintext
---
|
||
title: Snapshot
|
||
description: API reference for qiskit.extensions.Snapshot
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.extensions.Snapshot
|
||
---
|
||
|
||
# Snapshot
|
||
|
||
<Class id="qiskit.extensions.Snapshot" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.21/qiskit/extensions/simulator/snapshot.py" signature="Snapshot(label, snapshot_type='statevector', num_qubits=0, num_clbits=0, params=None)" modifiers="class">
|
||
Bases: [`qiskit.circuit.instruction.Instruction`](qiskit.circuit.Instruction "qiskit.circuit.instruction.Instruction")
|
||
|
||
Simulator snapshot instruction.
|
||
|
||
Create new snapshot instruction.
|
||
|
||
**Parameters**
|
||
|
||
* **label** (*str*) – the snapshot label for result data.
|
||
* **snapshot\_type** (*str*) – the type of the snapshot.
|
||
* **num\_qubits** (*int*) – the number of qubits for the snapshot type \[Default: 0].
|
||
* **num\_clbits** (*int*) – the number of classical bits for the snapshot type \[Default: 0].
|
||
* **params** (*list or None*) – the parameters for snapshot\_type \[Default: None].
|
||
|
||
**Raises**
|
||
|
||
**ExtensionError** – if snapshot label is invalid.
|
||
|
||
## Methods
|
||
|
||
### add\_decomposition
|
||
|
||
<Function id="qiskit.extensions.Snapshot.add_decomposition" signature="Snapshot.add_decomposition(decomposition)">
|
||
Add a decomposition of the instruction to the SessionEquivalenceLibrary.
|
||
</Function>
|
||
|
||
### assemble
|
||
|
||
<Function id="qiskit.extensions.Snapshot.assemble" signature="Snapshot.assemble()">
|
||
Assemble a QasmQobjInstruction
|
||
</Function>
|
||
|
||
### broadcast\_arguments
|
||
|
||
<Function id="qiskit.extensions.Snapshot.broadcast_arguments" signature="Snapshot.broadcast_arguments(qargs, cargs)">
|
||
Validation of the arguments.
|
||
|
||
**Parameters**
|
||
|
||
* **qargs** (*List*) – List of quantum bit arguments.
|
||
* **cargs** (*List*) – List of classical bit arguments.
|
||
|
||
**Yields**
|
||
|
||
*Tuple(List, List)* – A tuple with single arguments.
|
||
|
||
**Raises**
|
||
|
||
**CircuitError** – If the input is not valid. For example, the number of arguments does not match the gate expectation.
|
||
</Function>
|
||
|
||
### c\_if
|
||
|
||
<Function id="qiskit.extensions.Snapshot.c_if" signature="Snapshot.c_if(classical, val)">
|
||
Set a classical equality condition on this instruction between the register or cbit `classical` and value `val`.
|
||
|
||
<Admonition title="Note" type="note">
|
||
This is a setter method, not an additive one. Calling this multiple times will silently override any previously set condition; it does not stack.
|
||
</Admonition>
|
||
</Function>
|
||
|
||
### copy
|
||
|
||
<Function id="qiskit.extensions.Snapshot.copy" signature="Snapshot.copy(name=None)">
|
||
Copy of the instruction.
|
||
|
||
**Parameters**
|
||
|
||
**name** (*str*) – name to be given to the copied circuit, if None then the name stays the same.
|
||
|
||
**Returns**
|
||
|
||
**a copy of the current instruction, with the name**
|
||
|
||
updated if it was provided
|
||
|
||
**Return type**
|
||
|
||
[qiskit.circuit.Instruction](qiskit.circuit.Instruction "qiskit.circuit.Instruction")
|
||
</Function>
|
||
|
||
### inverse
|
||
|
||
<Function id="qiskit.extensions.Snapshot.inverse" signature="Snapshot.inverse()">
|
||
Special case. Return self.
|
||
</Function>
|
||
|
||
### is\_parameterized
|
||
|
||
<Function id="qiskit.extensions.Snapshot.is_parameterized" signature="Snapshot.is_parameterized()">
|
||
Return True .IFF. instruction is parameterized else False
|
||
</Function>
|
||
|
||
### qasm
|
||
|
||
<Function id="qiskit.extensions.Snapshot.qasm" signature="Snapshot.qasm()">
|
||
Return a default OpenQASM string for the instruction.
|
||
|
||
Derived instructions may override this to print in a different format (e.g. measure q\[0] -> c\[0];).
|
||
</Function>
|
||
|
||
### repeat
|
||
|
||
<Function id="qiskit.extensions.Snapshot.repeat" signature="Snapshot.repeat(n)">
|
||
Creates an instruction with gate repeated n amount of times.
|
||
|
||
**Parameters**
|
||
|
||
**n** (*int*) – Number of times to repeat the instruction
|
||
|
||
**Returns**
|
||
|
||
Containing the definition.
|
||
|
||
**Return type**
|
||
|
||
[qiskit.circuit.Instruction](qiskit.circuit.Instruction "qiskit.circuit.Instruction")
|
||
|
||
**Raises**
|
||
|
||
**CircuitError** – If n \< 1.
|
||
</Function>
|
||
|
||
### reverse\_ops
|
||
|
||
<Function id="qiskit.extensions.Snapshot.reverse_ops" signature="Snapshot.reverse_ops()">
|
||
For a composite instruction, reverse the order of sub-instructions.
|
||
|
||
This is done by recursively reversing all sub-instructions. It does not invert any gate.
|
||
|
||
**Returns**
|
||
|
||
**a new instruction with**
|
||
|
||
sub-instructions reversed.
|
||
|
||
**Return type**
|
||
|
||
[qiskit.circuit.Instruction](qiskit.circuit.Instruction "qiskit.circuit.Instruction")
|
||
</Function>
|
||
|
||
### soft\_compare
|
||
|
||
<Function id="qiskit.extensions.Snapshot.soft_compare" signature="Snapshot.soft_compare(other)">
|
||
Soft comparison between gates. Their names, number of qubits, and classical bit numbers must match. The number of parameters must match. Each parameter is compared. If one is a ParameterExpression then it is not taken into account.
|
||
|
||
**Parameters**
|
||
|
||
**other** (*instruction*) – other instruction.
|
||
|
||
**Returns**
|
||
|
||
are self and other equal up to parameter expressions.
|
||
|
||
**Return type**
|
||
|
||
bool
|
||
</Function>
|
||
|
||
### validate\_parameter
|
||
|
||
<Function id="qiskit.extensions.Snapshot.validate_parameter" signature="Snapshot.validate_parameter(parameter)">
|
||
Instruction parameters has no validation or normalization.
|
||
</Function>
|
||
|
||
## Attributes
|
||
|
||
### condition\_bits
|
||
|
||
<Attribute id="qiskit.extensions.Snapshot.condition_bits">
|
||
Get Clbits in condition.
|
||
|
||
**Return type**
|
||
|
||
`List`\[[`Clbit`](qiskit.circuit.Clbit "qiskit.circuit.classicalregister.Clbit")]
|
||
</Attribute>
|
||
|
||
### decompositions
|
||
|
||
<Attribute id="qiskit.extensions.Snapshot.decompositions">
|
||
Get the decompositions of the instruction from the SessionEquivalenceLibrary.
|
||
</Attribute>
|
||
|
||
### definition
|
||
|
||
<Attribute id="qiskit.extensions.Snapshot.definition">
|
||
Return definition in terms of other basic gates.
|
||
</Attribute>
|
||
|
||
### duration
|
||
|
||
<Attribute id="qiskit.extensions.Snapshot.duration">
|
||
Get the duration.
|
||
</Attribute>
|
||
|
||
### label
|
||
|
||
<Attribute id="qiskit.extensions.Snapshot.label">
|
||
Return snapshot label
|
||
</Attribute>
|
||
|
||
### name
|
||
|
||
<Attribute id="qiskit.extensions.Snapshot.name">
|
||
Return the name.
|
||
</Attribute>
|
||
|
||
### num\_clbits
|
||
|
||
<Attribute id="qiskit.extensions.Snapshot.num_clbits">
|
||
Return the number of clbits.
|
||
</Attribute>
|
||
|
||
### num\_qubits
|
||
|
||
<Attribute id="qiskit.extensions.Snapshot.num_qubits">
|
||
Return the number of qubits.
|
||
</Attribute>
|
||
|
||
### params
|
||
|
||
<Attribute id="qiskit.extensions.Snapshot.params">
|
||
return instruction params.
|
||
</Attribute>
|
||
|
||
### snapshot\_type
|
||
|
||
<Attribute id="qiskit.extensions.Snapshot.snapshot_type">
|
||
Return snapshot type
|
||
</Attribute>
|
||
|
||
### unit
|
||
|
||
<Attribute id="qiskit.extensions.Snapshot.unit">
|
||
Get the time unit of duration.
|
||
</Attribute>
|
||
</Class>
|
||
|