Example #1
0
def openqasm_result_obj_shots(task_metadata_shots, additional_metadata_openqasm):
    return GateModelTaskResult.construct(
        measurements=[[0, 0], [0, 1], [0, 1], [0, 1]],
        measuredQubits=[0, 1],
        taskMetadata=task_metadata_shots,
        additionalMetadata=additional_metadata_openqasm,
        resultTypes=[jaqcd.Probability()],
    )
    def _create_results_obj(
        results: List[Dict[str, Any]],
        circuit_ir: Program,
        simulation: StateVectorSimulation,
    ) -> GateModelTaskResult:
        result_dict = {
            "taskMetadata":
            TaskMetadata(id=str(uuid.uuid4()),
                         shots=simulation.shots,
                         deviceId=DefaultSimulator.DEVICE_ID),
            "additionalMetadata":
            AdditionalMetadata(action=circuit_ir),
        }
        if results:
            result_dict["resultTypes"] = results
        if simulation.shots:
            result_dict[
                "measurements"] = DefaultSimulator._formatted_measurements(
                    simulation)
            result_dict[
                "measuredQubits"] = DefaultSimulator._get_measured_qubits(
                    simulation.qubit_count)

        return GateModelTaskResult.construct(**result_dict)