qbraid.passes.qasm

Module for transforming and extracting data from OpenQASM programs.

Functions

depth(qasm_statements, counts)

Return the depth of a list of given qasm statements.

rebase(qasm, gateset[, require_predicates])

Rebases an OpenQASM 3 program according to a given basis gate set.

unfold_qasm2(qasm)

Returns a QASM copy with custom gates deconstructed and unsupported operations decomposed.

decompose_qasm3(qasm)

Decompose an OpenQASM 3 program.

decompose_qasm2(qasm)

Replace edge-case qelib1 gates with equivalent decomposition.

insert_gate_def(qasm3_str, gate_name[, ...])

Add gate definitions to an Open0QASM 3 string.

replace_gate_name(qasm, old_gate_name, ...)

Replace occurrences of a specified gate name in a QASM program string with a new gate name, while optionally enforcing the replacement even if the new gate name isn't in the predefined gate map.

add_stdgates_include(qasm_str)

Add 'include "stdgates.inc";' to the QASM string if it is missing.

remove_stdgates_include(qasm)

Remove 'include "stdgates.inc";' from the QASM string.

convert_qasm_pi_to_decimal(qasm)

Convert all instances of 'pi' in the QASM string to their decimal value.

normalize_qasm_gate_params(qasm)

Normalize the parameters of the gates in the QASM string using function composition.

remove_unused_gates(qasm)

Remove unused gate definitions from a QASM string.

has_measurements(program)

Check if the program has any measurement operations.

remove_measurements(program)

Remove all measurement operations from the program.

remove_include_statements(program)

Remove all include statements from the program.