Skip to content

Commit 4908b19

Browse files
authored
supporting status attribute and status dictionary item (#528)
* supporting status attribute and status property * naming
1 parent 9d346a6 commit 4908b19

File tree

1 file changed

+6
-3
lines changed
  • azure-quantum/azure/quantum/target/microsoft

1 file changed

+6
-3
lines changed

azure-quantum/azure/quantum/target/microsoft/result.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, data: Union[Dict, List]):
3838
super().__init__(data)
3939

4040
self._is_simple = True
41-
if hasattr(self, 'status') and self['status'] == "success":
41+
if self._is_succeeded():
4242
self._repr = self._item_result_table()
4343
self.summary = HTMLWrapper(self._item_result_summary_table())
4444
self.diagram = EstimatorResultDiagram(self.data().copy())
@@ -63,6 +63,9 @@ def __init__(self, data: Union[Dict, List]):
6363
# Add plot function for batching jobs
6464
self.plot = self._plot
6565
self.summary_data_frame = self._summary_data_frame
66+
67+
def _is_succeeded(self):
68+
return 'status' in self and self['status'] == "success"
6669

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

278281
def get_row(result):
279-
if 'status' in result and result['status'] == 'success':
282+
if self._is_succeeded():
280283
formatted = result["physicalCountsFormatted"]
281284

282285
return (
@@ -406,7 +409,7 @@ def _item_result_summary_table(self):
406409
return html
407410

408411
def _batch_result_table(self, indices):
409-
succeeded_item_indices = [i for i in indices if 'status' in self[i] and self[i]['status'] == 'success']
412+
succeeded_item_indices = [i for i in indices if self[i]._is_succeeded()]
410413
if len(succeeded_item_indices) == 0:
411414
print("None of the jobs succeeded")
412415
return ""

0 commit comments

Comments
 (0)