qasm2 module

class qasm2

Implements the qasm2 class. Use this class to import qasm2 compliant files to build a quantum circuit.

qasm2(self)

The default constructor.

Example:
>>> qa = qasm2()
Args:

None

Returns:

qasm2 object

Raises:

None.

load(self, filename, include_path, include_input_directory, strict)

Constructs a quantum circuit out of the instructions contained in the provided qasm2 file.

Example:
>>> qc = qa.load("C:\Sycamore\1\circuit_n12_m14_s0_e0_pEFGH.qasm")
Args:
filename (str):

The name of the source file containing the qasm2 code.

include_path (Optional(str)):

The path where to find the include files.

include_input_directory (Optional(str)):

Default: “append” Not used currently.

strict (bool):

default: False Relaxes strict adherence, for example inclusion of the default include file, OPENQASM2.0 declaration, and so on.

Returns:

The handle to the quantum circuit

Raises:

RuntimeError, if the input file has an error.

loads(self, qasm2string, include_path, include_input_directory, strict)

Constructs a quantum circuit out of the instructions contained in the provided qasm2 file.

Example:
>>> qc = qa.loads(myString)
Args:
qasm2string (str):

Python string containing the qasm2 code.

include_path (Optional(str)):

The path where to find the include files.

include_input_directory (Optional(str)):

Default: “append” Not used currently.

strict (bool):

default: False Relaxes strict adherence, for example inclusion of the default include file, OPENQASM2.0 declaration, and so on.

Returns:

The handle to the quantum circuit

Raises:

RuntimeError, if the input file has an error.