forked from microsoft/Quantum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOut-Plot.ps1
83 lines (66 loc) · 1.89 KB
/
Out-Plot.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
<#
.SYNOPSIS
This script plots the results from running gate count analysis on one
or more sets of integrals.
.PARAMETER GateCountData
Results obtained from Get-GateCount.
.PARAMETER MetricName
The name of the field to extract from each of the results passed to
this script.
#>
param(
[Parameter(ValueFromPipeline=$true)]
$GateCountData,
[string[]]
$MetricName = @("CNOTCount", "TotalTCount"),
[string]
$WindowTitle = "Get-GateCount"
)
begin {
$AllData = [System.Collections.ArrayList]::new();
$Script = @"
import os
import matplotlib.pyplot as plt
plt.style.use('ggplot')
plt.rcParams.update({'font.size': 28})
fig_size = plt.rcParams["figure.figsize"]
fig_size[0] = 16
fig_size[1] = 12
plt.rcParams["figure.figsize"] = fig_size
plt.rcParams.update({'figure.autolayout': True})
for results in data:
results['Name'] = os.path.splitext(os.path.basename(results['IntegralDataPath']))[0]
import pandas as pd
import numpy as np
df = pd.DataFrame(data)
# This formula is approximates the number of T-gates required to synthesize each arbitrary rotation gate.
df['TotalTCount'] = df['TCount'] - 4 * np.log2( 0.001 / df['RotationsCount']) * df['RotationsCount']
for metric_name in metric_names:
(
df
.pivot(index='Name', columns='Method', values=metric_name)
.plot
.barh()
)
plt.title(metric_name)
plt.gca().set_xscale('log')
fig = plt.gcf()
fig.tight_layout()
fig.canvas.set_window_title(window_title)
plt.show()
"@;
}
process {
$AllData.Add($GateCountData) | Out-Null;
}
end {
Invoke-Python `
-Source $Script `
-Variables @{
"data" = $AllData;
"metric_names" = $MetricName;
"window_title" = $WindowTitle;
}
}