From c37a01d73790126a0914d5137e88d579942d8a15 Mon Sep 17 00:00:00 2001 From: "REDMOND\\ivanbaso" Date: Tue, 21 Nov 2023 15:03:24 -0800 Subject: [PATCH] feedback --- .../azure/quantum/target/microsoft/result.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/azure-quantum/azure/quantum/target/microsoft/result.py b/azure-quantum/azure/quantum/target/microsoft/result.py index bd4707274..fe54f2f50 100644 --- a/azure-quantum/azure/quantum/target/microsoft/result.py +++ b/azure-quantum/azure/quantum/target/microsoft/result.py @@ -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 @@ -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. @@ -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()) @@ -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 ( @@ -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 "" @@ -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")