Skip to content

Commit

Permalink
Respond to CR
Browse files Browse the repository at this point in the history
  • Loading branch information
laurencap committed Nov 8, 2023
1 parent 1c61b0c commit 63d50e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
4 changes: 3 additions & 1 deletion src/braket/tasks/gate_model_quantum_task_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,13 @@ def get_compiled_circuit(self) -> Optional[str]:
"""
metadata = self.additional_metadata
if not metadata:
return
return None
if metadata.rigettiMetadata:
return metadata.rigettiMetadata.compiledProgram
elif metadata.oqcMetadata:
return metadata.oqcMetadata.compiledProgram
else:
return None

@staticmethod
def measurement_counts_from_measurements(measurements: np.ndarray) -> Counter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,25 +147,17 @@ def result_obj_1(task_metadata_shots, additional_metadata):


@pytest.fixture
def result_rigetti(task_metadata_shots, additional_metadata_rigetti):
result = GateModelTaskResult(
measurements=[[0, 0], [0, 1], [0, 1], [0, 1]],
measuredQubits=[0, 1],
taskMetadata=task_metadata_shots,
additionalMetadata=additional_metadata_rigetti,
)
return GateModelQuantumTaskResult.from_object(result)
def result_rigetti(result_obj_1, additional_metadata_rigetti):
result = GateModelQuantumTaskResult.from_object(result_obj_1)
result.additional_metadata = additional_metadata_rigetti
return result


@pytest.fixture
def result_oqc(task_metadata_shots, additional_metadata_oqc):
result = GateModelTaskResult(
measurements=[[0, 0], [0, 1], [0, 1], [0, 1]],
measuredQubits=[0, 1],
taskMetadata=task_metadata_shots,
additionalMetadata=additional_metadata_oqc,
)
return GateModelQuantumTaskResult.from_object(result)
def result_oqc(result_obj_1, additional_metadata_oqc):
result = GateModelQuantumTaskResult.from_object(result_obj_1)
result.additional_metadata = additional_metadata_oqc
return result


@pytest.fixture
Expand Down Expand Up @@ -341,7 +333,7 @@ def test_get_compiled_circuit_oqc(result_oqc, qasm2_program):
assert result_oqc.get_compiled_circuit() == qasm2_program


def test_get_compiled_circuit(result_obj_1):
def test_get_compiled_circuit_no_qhp_metadata(result_obj_1):
"""Test get_compiled_circuit method."""
result = GateModelQuantumTaskResult.from_object(result_obj_1)
assert result.get_compiled_circuit() is None
Expand Down

0 comments on commit 63d50e5

Please sign in to comment.