pyqasm.QasmModule

class QasmModule(name, program)[source]

Abstract class for a Qasm module

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

  • program (Program) – The original openqasm3 program.

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

__init__(name, program)[source]

Methods

__init__(name, program)

accept(visitor)

Accept a visitor for the mßodule

copy()

Return a deep copy of the module

depth()

Calculate the depth of the unrolled openqasm program.

has_barriers()

Check if the module has any barrier operations.

has_measurements()

Check if the module has any measurement operations.

populate_idle_qubits([in_place])

Populate the idle qubits in the module with identity gates

remove_barriers([in_place])

Remove the barrier operations

remove_idle_qubits([in_place])

Remove idle qubits from the module.

remove_includes([in_place])

Remove the include statements 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