qutip_qip.qasm

Importation and exportation of QASM circuits

Functions

circuit_to_qasm_str(qc)

Return QASM output of circuit object as string

print_qasm(qc)

Print QASM output of circuit object.

qasmu_gate(args[, N, target])

QASM U-gate as defined in the OpenQASM standard.

read_qasm(qasm_input[, mode, version, strmode])

Read OpenQASM intermediate representation (https://github.com/Qiskit/openqasm) and return a QubitCircuit and state inputs as specified in the QASM file.

save_qasm(qc, file_loc)

Save QASM output of circuit object to file.

qutip_qip.qasm.circuit_to_qasm_str(qc)[source]

Return QASM output of circuit object as string

Parameters
qcQubitCircuit

circuit object to produce QASM output for.

Returns
output: str

string corresponding to QASM output.

qutip_qip.qasm.print_qasm(qc)[source]

Print QASM output of circuit object.

Parameters
qcQubitCircuit

circuit object to produce QASM output for.

qutip_qip.qasm.read_qasm(qasm_input, mode='default', version='2.0', strmode=False)[source]

Read OpenQASM intermediate representation (https://github.com/Qiskit/openqasm) and return a QubitCircuit and state inputs as specified in the QASM file.

Parameters
qasm_inputstr

File location or String Input for QASM file to be imported. In case of string input, the parameter strmode must be True.

modestr

Parsing mode for the qasm file. - “default”: For predefined gates in qutip-qip, use the predefined version, otherwise use the custom gate defined in qelib1.inc. The predefined gate can usually be further processed (e.g. decomposed) within qutip-qip. - “predefined_only”: Use only the predefined gates in qutip-qip. - “external_only”: Use only the gate defined in qelib1.inc, except for CX and QASMU gate.

versionstr

QASM version of the QASM file. Only version 2.0 is currently supported.

strmodebool

if specified as True, indicates that qasm_input is in string format rather than from file.

Returns
qcQubitCircuit

Returns a QubitCircuit object specified in the QASM file.

qutip_qip.qasm.save_qasm(qc, file_loc)[source]

Save QASM output of circuit object to file.

Parameters
qcQubitCircuit

circuit object to produce QASM output for.