Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanbasov committed Nov 21, 2023
1 parent d5c945d commit c37a01d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions azure-quantum/azure/quantum/target/microsoft/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
##
__all__ = ['MicrosoftEstimatorResult']

from typing import Any, Dict, List, Optional, Union

import json
Expand All @@ -18,9 +20,6 @@ def __init__(self, content: str):
def _repr_html_(self):
return self.content

def is_succeeded(obj):
return 'status' in obj and obj['status'] == "success"

class MicrosoftEstimatorResult(dict):
"""
Microsoft Resource Estimator result.
Expand All @@ -40,7 +39,7 @@ def __init__(self, data: Union[Dict, List]):
super().__init__(data)

self._is_simple = True
if is_succeeded(self):
if MicrosoftEstimatorResult._is_succeeded(self):
self._repr = self._item_result_table()
self.summary = HTMLWrapper(self._item_result_summary_table())
self.diagram = EstimatorResultDiagram(self.data().copy())
Expand Down Expand Up @@ -281,7 +280,7 @@ def _summary_data_frame(self, **kwargs):
labels = labels[:len(self)]

def get_row(result):
if is_succeeded(result):
if MicrosoftEstimatorResult._is_succeeded(result):
formatted = result["physicalCountsFormatted"]

return (
Expand Down Expand Up @@ -411,8 +410,7 @@ def _item_result_summary_table(self):
return html

def _batch_result_table(self, indices):
succeeded_item_indices = [i for i in indices if is_succeeded(self[i])]

succeeded_item_indices = [i for i in indices if MicrosoftEstimatorResult._is_succeeded(self[i])]
if len(succeeded_item_indices) == 0:
print("None of the jobs succeeded")
return ""
Expand Down Expand Up @@ -474,7 +472,10 @@ def _batch_result_table(self, indices):

return html


@staticmethod
def _is_succeeded(obj):
return 'status' in obj and obj['status'] == "success"

class EstimatorResultDiagram:
def __init__(self, data):
data.pop("reportData")
Expand Down

0 comments on commit c37a01d

Please sign in to comment.