Skip to content

Commit

Permalink
update qdk (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
katymccl authored Jul 14, 2023
1 parent c8fde4c commit af9d0cf
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions azure-quantum/azure/quantum/target/microsoft/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
##
from typing import Any, Dict, List, Optional, Union

import json
import markdown


Expand All @@ -30,6 +31,8 @@ def __init__(self, data: Union[Dict, List]):
self._is_simple = True
self._repr = self._item_result_table()
self.summary = HTMLWrapper(self._item_result_summary_table())
self.diagram = EstimatorResultDiagram(self.data().copy())

elif isinstance(data, list):
super().__init__({idx: MicrosoftEstimatorResult(item_data)
for idx, item_data in enumerate(data)})
Expand Down Expand Up @@ -377,3 +380,24 @@ def _batch_result_table(self, indices):
html += "</ul></details>"

return html


class EstimatorResultDiagram:
def __init__(self, data):
data.pop("reportData")
self.data_json = json.dumps(data).replace(" ", "")
self.vis_lib = "https://cdn-aquavisualization-prod.azureedge.net/resource-estimation/index.js"
self.space = HTMLWrapper(self._space_diagram())
self.time = HTMLWrapper(self._time_diagram())

def _space_diagram(self):
html = f"""
<script src={self.vis_lib}></script>
<re-space-diagram data={self.data_json}></re-space-diagram>"""
return html

def _time_diagram(self):
html = f"""
<script src={self.vis_lib}></script>
<re-time-diagram data={self.data_json}></re-time-diagram>"""
return html

0 comments on commit af9d0cf

Please sign in to comment.