Skip to content

Commit

Permalink
Fix retrieve logic
Browse files Browse the repository at this point in the history
  • Loading branch information
nkanazawa1989 committed Jan 29, 2024
1 parent 7675cbb commit 357b13d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion qiskit_experiments/library/driven_freq_tuning/coefficient.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from qiskit_ibm_experiment.service import IBMExperimentService
from qiskit_ibm_experiment.exceptions import IBMApiError

from qiskit_experiments.framework.json import ExperimentDecoder
from qiskit_experiments.framework.backend_data import BackendData
from qiskit_experiments.framework.experiment_data import ExperimentData

Expand Down Expand Up @@ -223,11 +224,14 @@ def retrieve_coefficients_from_service(
RuntimeError: When stark_coefficients entry doesn't exist in the service.
"""
try:
if isinstance(qubit, (list, tuple)) and len(qubit) == 1:
qubit = qubit[0]
retrieved = service.analysis_results(
device_components=[f"Q{qubit}"],
result_type="stark_coefficients",
backend_name=backend_name,
sort_by=["creation_datetime:desc"],
json_decoder=ExperimentDecoder,
)
except (IBMApiError, ValueError) as ex:
raise RuntimeError(
Expand All @@ -238,7 +242,15 @@ def retrieve_coefficients_from_service(
"Analysis result of stark_coefficients is not found in the "
"experiment service. Run and save the result of StarkRamseyXYAmpScan."
)
return retrieved[0].result_data["value"]

result_data_dict = retrieved[0].result_data
if "_value" in result_data_dict:
# In IBM Experiment service, the result_data["value"] returns
# a display value for the experiment service webpage.
# Original data is stored in "_value".
# TODO: this must be handled by experiment service.
return result_data_dict["value"]
return result_data_dict["value"]


def retrieve_coefficients_from_backend(
Expand Down

0 comments on commit 357b13d

Please sign in to comment.