braket.default_simulator.openqasm.simulation_path module
- class braket.default_simulator.openqasm.simulation_path.FramedVariable(name: str, var_type: Any, value: Any, is_const: bool, frame_number: int)[source]
Bases:
objectVariable with frame tracking for proper scoping.
Each variable tracks which frame (scope level) it was declared in, enabling correct scope restoration when exiting blocks.
- property name: str
- property var_type: Any
- property value: Any
- property is_const: bool
- property frame_number: int
- class braket.default_simulator.openqasm.simulation_path.SimulationPath(instructions: list[GateOperation] | None = None, shots: int = 0, variables: dict[str, FramedVariable] | None = None, measurements: dict[int, list[int]] | None = None, frame_number: int = 0)[source]
Bases:
objectA single execution path in a branched simulation.
Each path maintains its own instruction sequence, shot allocation, classical variable state, measurement outcomes, and scope frame number. When a mid-circuit measurement causes branching, paths are deep-copied so that each branch evolves independently.
- property instructions: list[GateOperation]
- property shots: int
- property variables: dict[str, FramedVariable]
- property measurements: dict[int, list[int]]
- property frame_number: int
- branch() SimulationPath[source]
Create a deep copy of this path for branching.
Returns a new SimulationPath with independent copies of all mutable state (instructions, variables, measurements), so modifications to the child path do not affect the parent.
- enter_frame() int[source]
Enter a new variable scope frame.
Returns the previous frame number so it can be restored on exit.
- exit_frame(previous_frame: int) None[source]
Exit the current variable scope frame.
Removes all variables declared in frames newer than
previous_frameand restores the frame number.
- add_instruction(instruction: GateOperation) None[source]
Append a gate operation to this path’s instruction sequence.
- set_variable(name: str, var: FramedVariable) None[source]
Set a classical variable in this path’s variable state.
- get_variable(name: str) FramedVariable | None[source]
Get a classical variable from this path’s variable state.