test/runtime/fake_vqeruntime.py
def run(self, program_id, inputs, options, callback=None):
        """Run the fake program. Checks the input types."""

        if program_id != "qaoa":
            raise ValueError("program_id is not qaoa.")

        allowed_inputs = {
            "operator": PauliSumOp,
            "aux_operators": (list, type(None)),
            "ansatz": type(None),
            "initial_point": (np.ndarray, str),
            "optimizer": (Optimizer, dict),
            "shots": int,
            "measurement_error_mitigation": bool,
            "store_intermediate": bool,
            "reps": int,
            "use_pulse_efficient": bool,
            "use_swap_strategies": bool,
            "use_initial_mapping": bool,
            "alpha": float,
        }
        for arg, value in inputs.items():
            if not isinstance(value, allowed_inputs[arg]):
                raise ValueError(f"{arg} does not have the right type: {allowed_inputs[arg]}")

        allowed_options = {"backend_name": str}
        for arg, value in options.items():
            if not isinstance(value, allowed_options[arg]):
                raise ValueError(f"{arg} does not have the right type: {allowed_inputs[arg]}")

        if callback is not None:
            try:
                fake_job_id = "c2985khdm6upobbnmll0"
                fake_data = [3, np.arange(10), 1.3]
                _ = callback(fake_job_id, fake_data)
            except Exception as exc:
                raise ValueError("Callback failed") from exc

        return FakeVQEJob()
Run the fake program. Checks the input types.
Run the fake program. Checks the input types.
Run the fake program . Checks the input types .
def run(self, program_id, inputs, options, callback=None):
        if program_id != "qaoa":
            raise ValueError("program_id is not qaoa.")
        allowed_inputs = {
            "operator": PauliSumOp,
            "aux_operators": (list, type(None)),
            "ansatz": type(None),
            "initial_point": (np.ndarray, str),
            "optimizer": (Optimizer, dict),
            "shots": int,
            "measurement_error_mitigation": bool,
            "store_intermediate": bool,
            "reps": int,
            "use_pulse_efficient": bool,
            "use_swap_strategies": bool,
            "use_initial_mapping": bool,
            "alpha": float,
        }
        for arg, value in inputs.items():
            if not isinstance(value, allowed_inputs[arg]):
                raise ValueError(f"{arg} does not have the right type: {allowed_inputs[arg]}")
        allowed_options = {"backend_name": str}
        for arg, value in options.items():
            if not isinstance(value, allowed_options[arg]):
                raise ValueError(f"{arg} does not have the right type: {allowed_inputs[arg]}")
        if callback is not None:
            try:
                fake_job_id = "c2985khdm6upobbnmll0"
                fake_data = [3, np.arange(10), 1.3]
                _ = callback(fake_job_id, fake_data)
            except Exception as exc:
                raise ValueError("Callback failed") from exc
        return FakeVQEJob()
def run ( self , program_id , inputs , options , callback = None ) : if program_id != "qaoa" : raise ValueError ( "program_id is not qaoa." ) allowed_inputs = { "operator" : PauliSumOp , "aux_operators" : ( list , type ( None ) ) , "ansatz" : type ( None ) , "initial_point" : ( np . ndarray , str ) , "optimizer" : ( Optimizer , dict ) , "shots" : int , "measurement_error_mitigation" : bool , "store_intermediate" : bool , "reps" : int , "use_pulse_efficient" : bool , "use_swap_strategies" : bool , "use_initial_mapping" : bool , "alpha" : float , } for arg , value in inputs . items ( ) : if not isinstance ( value , allowed_inputs [ arg ] ) : raise ValueError ( f"{arg} does not have the right type: {allowed_inputs[arg]}" ) allowed_options = { "backend_name" : str } for arg , value in options . items ( ) : if not isinstance ( value , allowed_options [ arg ] ) : raise ValueError ( f"{arg} does not have the right type: {allowed_inputs[arg]}" ) if callback is not None : try : fake_job_id = "c2985khdm6upobbnmll0" fake_data = [ 3 , np . arange ( 10 ) , 1.3 ] _ = callback ( fake_job_id , fake_data ) except Exception as exc : raise ValueError ( "Callback failed" ) from exc return FakeVQEJob ( )
Run the fake program.
Run the fake program .
"""Run the fake program. Checks the input types."""
self
program_id
inputs
options
callback