Barriers

from mpqp import Barrier

A barrier is a purely cosmetic instruction. In fact, at execution it is removed because it could have a negative impact on the execution speed of the circuit (since it artificially increases the depth).

class Barrier(size=0)[source]

Bases: Instruction

Visual indicator of how the circuit can be divided.

Parameters

size (int) – Size of the barrier. If set to 0, it will be a dynamic instruction, always spanning the entirety of the circuit.

to_other_language(language=Language.QISKIT, qiskit_parameters=None)[source]

Transforms this instruction into the corresponding object in the language specified in the language arg.

By default, the instruction is translated to the corresponding one in Qiskit, since it is the interface we use to generate the OpenQASM code.

In the future, we will generate the OpenQASM code on our own, and this method will be used only for complex objects that are not tractable by OpenQASM (like hybrid structures).

Parameters
  • language (Language) – Enum representing the target language.

  • qiskit_parameters (Optional[set['Parameter']]) – We need to keep track of the parameters passed to qiskit in order not to define twice the same parameter. Defaults to set().

Returns

The corresponding instruction (gate or measure) in the target language.

size

See parameter description.