autoqasm.program.pragmas module

AutoQASM supported pragmas.

Pragmas specify how a program should be compiled or executed. In AutoQASM, we support them via with statements. For example:

@aq.main
def pragma_example() -> None:
    with aq.verbatim():
        h(0)
        cnot(0, 1)
    x(0)

The verbatim pragma would then apply to the h and cnot, but not the x.

class autoqasm.program.pragmas.PragmaType(*values)[source]

Bases: StrEnum

Values used in pragma statements.

VERBATIM = 'braket verbatim'

Denotes a box as a verbatim block.

autoqasm.program.pragmas.verbatim(annotations: str | Iterable[str] | None = None) None[source]

Context management protocol that, when used with a with statement, wraps the code block in a verbatim block.

A verbatim block specifies that operations contained within the block are to be executed as programmed without compilation or modification of any sort.

Parameters:

annotations (str | Iterable[str] | None) – Annotations for the box.

Raises:

errors.VerbatimBlockNotAllowed – If a verbatim block is not allowed at this point in the program; for example, if the target device does not support verbatim blocks.