/
goodness.py
189 lines (162 loc) · 8.8 KB
/
goodness.py
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
""" Goodness sections """
#***************************************************************************************************
# Copyright 2015, 2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
# Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights
# in this software.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0 or in the LICENSE file in the root pyGSTi directory.
#***************************************************************************************************
from pygsti.report.section import Section as _Section
class GoodnessSection(_Section):
_HTML_TEMPLATE = 'tabs/Goodness.html'
@_Section.figure_factory(1)
def final_model_fit_colorscatter_plot(workspace, switchboard=None, linlog_percentile=5, comm=None, bgcolor='white',
**kwargs):
return workspace.ColorBoxPlot(
switchboard.objfn_builder_modvi, switchboard.circuits_final,
switchboard.modvi_ds, switchboard.mdl_current_modvi,
linlg_pcntle=linlog_percentile / 100,
typ="scatter", comm=comm, bgcolor=bgcolor
)
@_Section.figure_factory(4)
def final_model_fit_progress_table(workspace, switchboard=None, max_lengths=None, comm=None, **kwargs):
return workspace.FitComparisonTable(
max_lengths, switchboard.circuits_all, switchboard.mdl_all_modvi,
switchboard.modvi_ds, switchboard.objfn_builder_modvi, 'L', comm=comm
)
@_Section.figure_factory(4)
def final_model_fit_progress_bar_plot(workspace, switchboard=None, max_lengths=None, comm=None, **kwargs):
return workspace.FitComparisonBarPlot(
max_lengths, switchboard.circuits_all, switchboard.mdl_all_modvi,
switchboard.modvi_ds, switchboard.objfn_builder_modvi, 'L', comm=comm
)
class GoodnessColorBoxPlotSection(_Section):
_HTML_TEMPLATE = 'tabs/Goodness_colorboxplot.html'
@_Section.figure_factory(1)
def final_model_fit_colorbox_plot(workspace, switchboard=None, linlog_percentile=5, brevity=0, comm=None,
bgcolor='white', **kwargs):
qty = workspace.ColorBoxPlot(
switchboard.objfn_builder_modvi, switchboard.circuits_current,
switchboard.modvi_ds, switchboard.mdl_current_modvi,
linlg_pcntle=linlog_percentile / 100, comm=comm, bgcolor=bgcolor
)
if brevity < 1:
qty.set_render_options(click_to_display=False, valign='bottom')
return qty
@_Section.figure_factory(1)
def final_model_tvd_colorbox_plot(workspace, switchboard=None, brevity=0, comm=None, bgcolor='white', **kwargs):
qty = workspace.ColorBoxPlot(
'tvd', switchboard.circuits_current, switchboard.modvi_ds, switchboard.mdl_current_modvi,
comm=comm, bgcolor=bgcolor
)
if brevity < 1:
qty.set_render_options(click_to_display=False, valign='bottom')
return qty
@_Section.figure_factory()
def maxlength_switchboard1(workspace, switchboard=None, switchbd_maxlengths=None, **kwargs):
maxLView = [False, False, False, len(switchbd_maxlengths) > 1]
return switchboard.view(maxLView, 'v6')
class GoodnessScalingSection(_Section):
_HTML_TEMPLATE = 'tabs/Goodness_scaling.html'
@_Section.figure_factory(1)
def final_model_fit_colorscatter_plot_scl(workspace, switchboard=None, linlog_percentile=5, comm=None,
bgcolor='white', **kwargs):
return workspace.ColorBoxPlot(
switchboard.objfn_builder, switchboard.circuits_current,
switchboard.eff_ds, switchboard.mdl_current,
linlg_pcntle=linlog_percentile / 100,
typ="scatter", comm=comm, bgcolor=bgcolor
)
@_Section.figure_factory(1)
def final_model_fit_colorbox_plot_scl(workspace, switchboard=None, linlog_percentile=5, brevity=0, comm=None,
bgcolor='white', **kwargs):
qty = workspace.ColorBoxPlot(
switchboard.objfn_builder, switchboard.circuits_current,
switchboard.eff_ds, switchboard.mdl_current,
linlg_pcntle=linlog_percentile / 100,
comm=comm, bgcolor=bgcolor
)
if brevity < 1:
qty.set_render_options(click_to_display=False, valign='bottom')
return qty
@_Section.figure_factory()
def final_model_fit_histogram_scl(workspace, switchboard=None, linlog_percentile=5, comm=None, bgcolor='white',
**kwargs):
return workspace.ColorBoxPlot(
switchboard.objfn_builder, switchboard.circuits_current,
switchboard.eff_ds, switchboard.mdl_current,
linlg_pcntle=linlog_percentile / 100,
typ="histogram", comm=comm, bgcolor=bgcolor
)
@_Section.figure_factory(4)
def final_model_fit_progress_table_scl(workspace, switchboard=None, max_lengths=None, comm=None, **kwargs):
return workspace.FitComparisonTable(
max_lengths, switchboard.circuits_all, switchboard.mdl_all,
switchboard.eff_ds, switchboard.objfn_builder, 'L', comm=comm
)
@_Section.figure_factory(4)
def final_model_fit_progress_bar_plot_scl(workspace, switchboard=None, max_lengths=None, comm=None, **kwargs):
return workspace.FitComparisonBarPlot(
max_lengths, switchboard.circuits_all, switchboard.mdl_all,
switchboard.eff_ds, switchboard.objfn_builder, 'L', comm=comm
)
@_Section.figure_factory(1)
def data_scaling_colorbox_plot(workspace, switchboard=None, comm=None, bgcolor='white', **kwargs):
return workspace.ColorBoxPlot(
'scaling', switchboard.circuits_final, switchboard.eff_ds, None,
submatrices=switchboard.scaled_submxs_dict, comm=comm,
bgcolor=bgcolor
)
class GoodnessUnmodeledSection(_Section):
_HTML_TEMPLATE = 'tabs/Goodness_unmodeled.html'
@_Section.figure_factory(1)
def unmodeled_error_budget_table(workspace, switchboard=None, **kwargs):
return workspace.WildcardBudgetTable(switchboard.wildcard_budget)
@_Section.figure_factory(4)
def final_model_fit_progress_bar_plot_ume(workspace, switchboard=None, max_lengths=None, comm=None, **kwargs):
return workspace.FitComparisonBarPlot(
max_lengths, switchboard.circuits_all, switchboard.mdl_all,
switchboard.modvi_ds, switchboard.objfn_builder_modvi, 'L',
wildcard=switchboard.wildcard_budget, comm=comm
)
@_Section.figure_factory(4)
def final_model_fit_progress_table_ume(workspace, switchboard=None, max_lengths=None, comm=None, **kwargs):
return workspace.FitComparisonTable(
max_lengths, switchboard.circuits_all, switchboard.mdl_all,
switchboard.modvi_ds, switchboard.objfn_builder_modvi, 'L',
wildcard=switchboard.wildcard_budget, comm=comm
)
@_Section.figure_factory()
def final_model_fit_histogram_ume(workspace, switchboard=None, linlog_percentile=5, comm=None, bgcolor='white',
**kwargs):
return workspace.ColorBoxPlot(
switchboard.objfn_builder_modvi, switchboard.circuits_current,
switchboard.modvi_ds, switchboard.mdl_current,
linlg_pcntle=linlog_percentile / 100,
typ="histogram", wildcard=switchboard.wildcard_budget,
comm=comm, bgcolor=bgcolor
)
@_Section.figure_factory(1)
def final_model_fit_colorbox_plot_ume(workspace, switchboard=None, linlog_percentile=5, brevity=0, comm=None,
bgcolor='white', **kwargs):
qty = workspace.ColorBoxPlot(
switchboard.objfn_builder_modvi, switchboard.circuits_current,
switchboard.modvi_ds, switchboard.mdl_current,
linlg_pcntle=linlog_percentile / 100,
wildcard=switchboard.wildcard_budget, comm=comm,
bgcolor=bgcolor
)
if brevity < 1:
qty.set_render_options(click_to_display=False, valign='bottom')
return qty
@_Section.figure_factory(1)
def final_model_fit_colorscatter_plot_ume(workspace, switchboard=None, linlog_percentile=5, comm=None,
bgcolor='white', **kwargs):
return workspace.ColorBoxPlot(
switchboard.objfn_builder_modvi, switchboard.circuits_current,
switchboard.modvi_ds, switchboard.mdl_current,
linlg_pcntle=linlog_percentile / 100, typ="scatter",
wildcard=switchboard.wildcard_budget, comm=comm,
bgcolor=bgcolor
)