autoqasm.simulator.program_context module

class autoqasm.simulator.program_context.QubitTable[source]

Bases: Table

get_by_identifier(identifier: Identifier | IndexedIdentifier) tuple[int][source]
get_by_identifier(identifier: IndexedIdentifier) tuple[int]

Convenience method to get an element with a possibly indexed identifier.

Parameters:

identifier (Union[Identifier, IndexedIdentifier]) – The identifier to retrieve.

Returns:

tuple[int] – The qubit indices associated with the given identifier.

static get_qubit_indices(identifier: IndexedIdentifier) list[IntegerLiteral | RangeDefinition | DiscreteSet][source]

Gets the qubit indices from a given indexed identifier.

Parameters:

identifier (IndexedIdentifier) – The identifier representing the qubit indices.

Raises:

IndexError – Index consists of multiple dimensions.

Returns:

list[IntegerLiteral | RangeDefinition | DiscreteSet] – The qubit indices corresponding to the given indexed identifier.

get_qubit_size(identifier: Identifier | IndexedIdentifier) int[source]

Gets the number of qubit indices for the given identifier.

Parameters:

identifier (Union[Identifier, IndexedIdentifier]) – The identifier representing the qubit indices.

Returns:

int – The number of qubit indices contained in the given identifier.

class autoqasm.simulator.program_context.McmProgramContext(circuit: Circuit | None = None)[source]

Bases: ProgramContext

Parameters:

circuit (Optional[Circuit]) – A partially-built circuit to continue building with this context. Default: None.

pop_instructions() list[GateOperation][source]

Returns the list of instructions and removes them from the context.

Returns:

list[GateOperation] – The list of instructions from the context.

add_output(output_name: str) None[source]

Adds an output with the given name.

Parameters:

output_name (str) – The output name to add.

save_output_values() None[source]

Saves the shot data to the outputs list. If no outputs have been added explicitly, all symbols in the current scope are added to the outputs list.