Exporter
class Exporter(includes=('stdgates.inc'), basis_gates=('U'), disable_constants=False, alias_classical_registers=False, indent=' ')
Bases: object
QASM3 expoter main class.
Parameters
- includes (
Sequence
[str
]) – the filenames that should be emitted as includes. These files will be parsed for gates, and any objects dumped from this exporter will use those definitions where possible. - basis_gates (
Sequence
[str
]) – the basic defined gate set of the backend. - disable_constants (
bool
) – ifTrue
, always emit floating-point constants for numeric parameter values. IfFalse
(the default), then values close to multiples of QASM 3 constants (pi
,euler
, andtau
) will be emitted in terms of those constants instead, potentially improving accuracy in the output. - alias_classical_registers (
bool
) – IfTrue
, then classical bit and classical register declarations will look similar to quantum declarations, where the whole set of bits will be declared in a flat array, and the registers will just be aliases to collections of these bits. This is inefficient for running OpenQASM 3 programs, however, and may not be well supported on backends. Instead, the default behaviour ofFalse
means that individual classical registers will gain their ownbit[size] register;
declarations, and looseClbit
s will go onto their own declaration. In this form, eachClbit
must be in either zero or oneClassicalRegister
s. - indent (
str
) – the indentation string to use for each level within an indented block. Can be set to the empty string to disable indentation.
Methods
dump
Exporter.dump(circuit, stream)
Convert the circuit to QASM 3, dumping the result to a file or text stream.
dumps
Exporter.dumps(circuit)
Convert the circuit to QASM 3, returning the result as a string.
Was this page helpful?
Report a bug or request content on GitHub.