qbraid.interface.qbraid_qasm3 package

Submodules

qbraid.interface.qbraid_qasm3.circuit_drawer module

Takes in OpenQASM 3 code and outputs an ASCII circuit representation

is_valid_gate(line)[source]

Checks if input string line is a valid OPENQASM gate

parse_gate_type(line, gates)[source]

Returns gate type and params of a line

class Gate(line, num_qregs, num_cregs)[source]

Bases: object

An individual gate in the circuit

Initializes a gate

parse_qregs(line)[source]

Gets the quantum registers associated with the gate

parse_cregs(line)[source]

Gets the classical registers associated with the gate

get_height()[source]

Gets the height of the gate

get_width()[source]

Gets the width of the gate

apply_gate_at_pos(gate_str, mat, pos)[source]

Adds the gate at the given y coordinate in the matrix representation

mat()[source]

Outputs a matrix representation of the gate

get_collision(circuit, g)[source]

Gets the collision position of a gate

add_gate(circuit, g, pos, reg_idxes)[source]

Adds a gate to the circuit

add_moment(circuit, moment)[source]

Adds a moment to the circuit

get_circuit_height(qasm_str)[source]

Gets the number of qubit and classical registers in the circuit

get_collision_before_pos(circuit, x, y)[source]

Gets the position of nearest collision with another gate

add_wires(circuit, g, num_qregs, pos)[source]

Adds wires to connect gates

add_cregs(circuit, num_cregs, end_pos)[source]

Adds classical registers to the circuit

extend_qregs(circuit, num_qregs, end_pos)[source]

Extends the quantum registers to the end of the circuit

can_add_gate(m_qregs, m_cregs, gate)[source]

Checks if a gate can be added to a moment

get_moments(gates)[source]

Splits up the circuit into moments

draw_circuit(qasm_str)[source]

Iterates over the input string and returns the gates

qbraid.interface.qbraid_qasm3.circuits module

Module containing qasm programs used for testing

qasm3_bell()[source]

Returns OpenQASM3 bell circuit

Return type

str

qasm3_shared15()[source]

Returns OpenQASM3 15 gate test circuit.

Return type

str

create_gateset_qasm(max_operands)[source]

gets qasm for gateset with max_operands

Return type

ndarray

qbraid.interface.qbraid_qasm3.tools module

Module containing OpenQASM 3 tools

qasm3_qubits(qasmstr)[source]

Get number of qasm qubits.

Parameters

qasmstr (str) – OpenQASM 3 string

Return type

List[str]

Returns

List of qubits in the circuit

qasm3_num_qubits(qasmstr)[source]

Calculate number of qubits in a qasm3 string

Return type

int

qasm3_depth(qasmstr)[source]

Calculates circuit depth of OpenQASM 3 string

Return type

int

convert_to_qasm3(qasm2_str)[source]

Convert a QASM 2.0 string to QASM 3.0 string

Parameters

qasm2_str (str) – QASM 2.0 string