pyqasm.Qasm3Module

class Qasm3Module(name, program, statements)[source]

A module representing an openqasm3 quantum program.

Parameters:
  • name (str) – Name of the module.

  • program (Program) – The original openqasm3 program.

  • statements (list[Statement]) – list of openqasm3 Statements.

__init__(name, program, statements)[source]

Methods

__init__(name, program, statements)

accept(visitor)

Accept a visitor for the module

copy()

Return a deep copy of the module

depth()

Calculate the depth of the unrolled openqasm program.

from_program(program)

Construct a Qasm3Module from a given openqasm3.ast.Program object

has_measurements()

Check if the module has any measurement operations.

remove_barriers([in_place])

Remove the barrier operations

remove_idle_qubits([in_place])

Remove idle qubits from the module.

remove_measurements([in_place])

Remove the measurement operations

reverse_qubit_order([in_place])

Reverse the order of qubits in the module

unroll(**kwargs)

Unroll the module into basic qasm operations

validate()

Validate the module

Attributes

name

Returns the name of the module.

num_clbits

Returns the number of classical bits in the circuit.

num_qubits

Returns the number of qubits in the circuit.

original_program

Returns the program AST for the original qasm supplied by the user

unrolled_ast

Returns the unrolled AST for the module

unrolled_qasm

Returns the unrolled qasm for the given module