qilisdk.utils.openqasm2

Attributes

OPENQASM2_MAP

Functions

to_qasm2(→ str)

Convert the circuit to an OpenQASM 2.0 formatted string.

to_qasm2_file(→ None)

Save the QASM representation to a file.

from_qasm2(→ qilisdk.digital.circuit.Circuit)

Parse an OpenQASM 2.0 string and create a corresponding Circuit instance.

from_qasm2_file(→ qilisdk.digital.circuit.Circuit)

Read an OpenQASM 2.0 file and create a corresponding Circuit instance.

Module Contents

OPENQASM2_MAP: dict[type[qilisdk.digital.gates.Gate], str][font]
to_qasm2(circuit: qilisdk.digital.circuit.Circuit) str[font]

Convert the circuit to an OpenQASM 2.0 formatted string.

Paràmetres:

circuit – The circuit to convert to OpenQASM 2.0.

Retorna:

The OpenQASM 2.0 representation of the circuit.

Tipus de retorn:

str

to_qasm2_file(circuit: qilisdk.digital.circuit.Circuit, filename: str) None[font]

Save the QASM representation to a file.

Paràmetres:
  • circuit – The circuit to convert to OpenQASM 2.0.

  • filename (str) – The path to the file where the QASM code will be saved.

from_qasm2(qasm_str: str) qilisdk.digital.circuit.Circuit[font]

Parse an OpenQASM 2.0 string and create a corresponding Circuit instance.

This parser supports the following instructions:
  • Quantum register declaration (e.g., «qreg q[3];»)

  • Classical register declaration (ignored)

  • Gate instructions (one-qubit and two-qubit gates)

  • Measurement instructions (e.g., «measure q[0] -> c[0];»)

Paràmetres:

qasm_str (str) – The QASM string to parse.

Retorna:

The constructed Circuit object.

Tipus de retorn:

Circuit

from_qasm2_file(filename: str) qilisdk.digital.circuit.Circuit[font]

Read an OpenQASM 2.0 file and create a corresponding Circuit instance.

Paràmetres:

filename (str) – The path to the QASM file.

Retorna:

The reconstructed Circuit object.

Tipus de retorn:

Circuit