pytket.qasm
pytket.qasm#
Circuit
objects can be converted to and from OpenQASM, although we do not support all operations.
In particular, we do not currently support:
Importing from libraries other than “qelib1”
Ability to interpret gates acting on a whole register in the OpenQASM style
Any pytket Circuit
that is exported to this format should be valid for importing again as a Circuit
, making this a convenient file format
to save your Circuit
objects.
However, we do support symbolic parameters of gates, both on import and export.
Note
Unlke pytket backends the qasm converters do not handle implicit qubit permutations . In other words if a circuit containing an implicit qubit permutation is converted to a qasm file the implicit permutation will not be accounted for and the circuit will be missing this permutation when reimported.
Parser from OPENQASM to tket Circuits
- pytket.qasm.circuit_from_qasm(input_file: Union[str, os.PathLike[Any]], encoding: str = 'utf-8') pytket.circuit.Circuit #
A method to generate a tket Circuit from a qasm file
- pytket.qasm.circuit_from_qasm_io(stream_in: TextIO) pytket.circuit.Circuit #
A method to generate a tket Circuit from a qasm text stream
- pytket.qasm.circuit_from_qasm_str(qasm_str: str) pytket.circuit.Circuit #
A method to generate a tket Circuit from a qasm str
- pytket.qasm.circuit_from_qasm_wasm(input_file: Union[str, os.PathLike[Any]], wasm_file: Union[str, os.PathLike[Any]], encoding: str = 'utf-8') pytket.circuit.Circuit #
A method to generate a tket Circuit from a qasm str and external WASM module.
- pytket.qasm.circuit_to_qasm(circ: pytket.circuit.Circuit, output_file: str, header: str = 'qelib1') None #
A method to generate a qasm file from a tket Circuit. Note that this will not account for implicit qubit permutations in the Circuit.
- pytket.qasm.circuit_to_qasm_io(circ: pytket.circuit.Circuit, stream_out: TextIO, header: str = 'qelib1', include_gate_defs: Optional[Set[str]] = None) None #
A method to generate a qasm text stream from a tket Circuit. Note that this will not account for implicit qubit permutations in the Circuit.
- pytket.qasm.circuit_to_qasm_str(circ: pytket.circuit.Circuit, header: str = 'qelib1') str #
A method to generate a qasm str from a tket Circuit. Note that this will not account for implicit qubit permutations in the Circuit.