Skip to content

Commit

Permalink
supporting status attribute and status property
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanbasov committed Nov 21, 2023
1 parent aea0f96 commit 75c8fbd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions azure-quantum/azure/quantum/target/microsoft/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, data: Union[Dict, List]):
super().__init__(data)

self._is_simple = True
if hasattr(self, 'status') and self['status'] == "success":
if self.__is_succeeded():
self._repr = self._item_result_table()
self.summary = HTMLWrapper(self._item_result_summary_table())
self.diagram = EstimatorResultDiagram(self.data().copy())
Expand All @@ -63,6 +63,9 @@ def __init__(self, data: Union[Dict, List]):
# Add plot function for batching jobs
self.plot = self._plot
self.summary_data_frame = self._summary_data_frame

def __is_succeeded(self):
return 'status' in self and self['status'] == "success"

def data(self, idx: Optional[int] = None) -> Any:
"""
Expand Down Expand Up @@ -276,7 +279,7 @@ def _summary_data_frame(self, **kwargs):
labels = labels[:len(self)]

def get_row(result):
if 'status' in result and result['status'] == 'success':
if self.__is_succeeded():
formatted = result["physicalCountsFormatted"]

return (
Expand Down Expand Up @@ -406,7 +409,7 @@ def _item_result_summary_table(self):
return html

def _batch_result_table(self, indices):
succeeded_item_indices = [i for i in indices if 'status' in self[i] and self[i]['status'] == 'success']
succeeded_item_indices = [i for i in indices if self[i].__is_succeeded()]
if len(succeeded_item_indices) == 0:
print("None of the jobs succeeded")
return ""
Expand Down

0 comments on commit 75c8fbd

Please sign in to comment.