microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
source/npm/qsharp/ux/data.ts
81lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | export type ReData = { |
| 5 | status: string; |
| 6 | jobParams: any; |
| 7 | physicalCounts: any; |
| 8 | physicalCountsFormatted: any; |
| 9 | logicalQubit: any; |
| 10 | tfactory: any; |
| 11 | errorBudget: any; |
| 12 | logicalCounts: any; |
| 13 | frontierEntries: FrontierEntry[]; |
| 14 | }; |
| 15 | |
| 16 | export type SingleEstimateResult = { |
| 17 | status: string; |
| 18 | jobParams: any; |
| 19 | physicalCounts: any; |
| 20 | physicalCountsFormatted: any; |
| 21 | logicalQubit: any; |
| 22 | tfactory: any; |
| 23 | errorBudget: any; |
| 24 | logicalCounts: any; |
| 25 | }; |
| 26 | |
| 27 | export type FrontierEntry = { |
| 28 | logicalQubit: any; |
| 29 | tfactory: any; |
| 30 | errorBudget: any; |
| 31 | physicalCounts: any; |
| 32 | physicalCountsFormatted: any; |
| 33 | }; |
| 34 | |
| 35 | export function CreateSingleEstimateResult( |
| 36 | input: ReData, |
| 37 | frontierEntryIndex?: number, |
| 38 | ): SingleEstimateResult { |
| 39 | if ( |
| 40 | frontierEntryIndex == undefined || |
| 41 | input.frontierEntries == null || |
| 42 | input.frontierEntries.length === 0 |
| 43 | ) { |
| 44 | return input; |
| 45 | } else { |
| 46 | if ( |
| 47 | frontierEntryIndex < 0 || |
| 48 | frontierEntryIndex >= input.frontierEntries.length |
| 49 | ) { |
| 50 | frontierEntryIndex = 0; |
| 51 | } |
| 52 | |
| 53 | const entry = input.frontierEntries[frontierEntryIndex]; |
| 54 | return { |
| 55 | status: input.status, |
| 56 | jobParams: input.jobParams, |
| 57 | physicalCounts: entry.physicalCounts, |
| 58 | physicalCountsFormatted: entry.physicalCountsFormatted, |
| 59 | logicalQubit: entry.logicalQubit, |
| 60 | tfactory: entry.tfactory, |
| 61 | errorBudget: entry.errorBudget, |
| 62 | logicalCounts: input.logicalCounts, |
| 63 | }; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | export type CircuitProps = { |
| 68 | title: string; |
| 69 | circuit?: CircuitGroup; |
| 70 | errorHtml?: string; |
| 71 | targetProfile: string; |
| 72 | /** Circuit was generated by running the simulator */ |
| 73 | simulated: boolean; |
| 74 | /** Circuit is still being generated */ |
| 75 | calculating: boolean; |
| 76 | isEditable: boolean; |
| 77 | editCallback?: (fileData: CircuitGroup) => void; |
| 78 | runCallback?: () => void; |
| 79 | }; |
| 80 | |
| 81 | export type CircuitGroup = import("./circuit-vis/circuit").CircuitGroup; |
| 82 | |