InstructionSet
class qiskit.circuit.InstructionSet(*, resource_requester=None)
Bases: object
Instruction collection, and their contexts.
New collection of instructions.
The context (qargs
and cargs
that each instruction is attached to) is also stored separately for each instruction.
Parameters
resource_requester (Callable[..., ClassicalRegister |Clbit] | None) –
A callable that takes in the classical resource used in the condition, verifies that it is present in the attached circuit, resolves any indices into concrete Clbit
instances, and returns the concrete resource. If this is not given, specifying a condition with an index is forbidden, and all concrete Clbit
and ClassicalRegister
resources will be assumed to be valid.
The callback resource_requester
assumes that a call implies that the resource will now be used. It may throw an error if the resource is not valid for usage.
Attributes
cargs
Legacy getter for the cargs components of an instruction set. This does not support mutation.
instructions
Legacy getter for the instruction components of an instruction set. This does not support mutation.
qargs
Legacy getter for the qargs components of an instruction set. This does not support mutation.
Methods
add
add(instruction, qargs=None, cargs=None)
Add an instruction and its context (where it is attached).
inverse
inverse(annotated=False)
Invert all instructions.
It is preferable to take the inverse before appending the gate(s) to the circuit.
Parameters
annotated (bool) –