Skip to content

Commit

Permalink
fix: Use explicit ProgramType as Python3.9 does not support type para…
Browse files Browse the repository at this point in the history
…meter lists
  • Loading branch information
ltnln committed Jul 15, 2024
1 parent 87d342b commit fdfa8c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/braket/aws/aws_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
from braket.devices import Devices
from braket.devices.device import Device
from braket.emulators import Emulator
from braket.emulators.emulator_passes import ProgramType
from braket.ir.blackbird import Program as BlackbirdProgram
from braket.ir.openqasm import Program as OpenQasmProgram
from braket.parametric.free_parameter import FreeParameter
Expand Down Expand Up @@ -931,9 +932,9 @@ def validate(
self.emulator.run_validation_passes(task_specification)
return

def run_emulator_passes[
ProgramType
](self, task_specification: ProgramType, apply_noise_model: bool = True) -> ProgramType:
def run_emulator_passes(
self, task_specification: ProgramType, apply_noise_model: bool = True
) -> ProgramType:
"""
Runs all emulator passes and returns the modified program, which should be the same
type as the input program.
Expand Down
6 changes: 3 additions & 3 deletions src/braket/emulators/emulator_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from abc import ABC
from typing import Iterable, Union

from braket.emulators.emulator_passes import EmulatorPass
from braket.emulators.emulator_passes import EmulatorPass, ProgramType
from braket.emulators.emulator_passes.criteria import EmulatorCriterion


class EmulatorInterface(ABC):
def __init__(self, emulator_passes: Iterable[EmulatorPass] = None):
self._emulator_passes = emulator_passes if emulator_passes is not None else []

def run_program_passes[ProgramType](self, task_specification: ProgramType) -> ProgramType:
def run_program_passes(self, task_specification: ProgramType) -> ProgramType:
"""
This method passes the input program through the EmulatorPasses contained
within this emulator. An emulator pass may simply validate a program or may
Expand All @@ -27,7 +27,7 @@ def run_program_passes[ProgramType](self, task_specification: ProgramType) -> Pr
task_specification = emulator_pass(task_specification)
return task_specification

def run_validation_passes[ProgramType](self, task_specification: ProgramType) -> None:
def run_validation_passes(self, task_specification: ProgramType) -> None:
"""
This method passes the input program through EmulatorPasses that perform
only validation, without modifying the input program.
Expand Down

0 comments on commit fdfa8c0

Please sign in to comment.