pygsti.report.fogidiagram

Defines the FOGIDiagram class and supporting functionality.

Module Contents

Classes

FOGIDiagram

A diagram of the first-order-gauge-invariant (FOGI) quantities of a model.

FOGIGraphDiagram

A diagram of the first-order-gauge-invariant (FOGI) quantities of a model.

FOGISvgGraphDiagram

A diagram of the first-order-gauge-invariant (FOGI) quantities of a model.

FOGIVisNetworkGraphDiagram

A diagram of the first-order-gauge-invariant (FOGI) quantities of a model.

FOGIDetailTable

A diagram of the first-order-gauge-invariant (FOGI) quantities of a model.

FOGIMultiscaleGridDiagram

A diagram of the first-order-gauge-invariant (FOGI) quantities of a model.

FOGIStackedBarDiagram

A diagram of the first-order-gauge-invariant (FOGI) quantities of a model.

Functions

_create_errgen_op(vec, list_of_mxs)

_is_dependent(infos_by_type)

_dstr(d, joinstr='<br>')

_fmt_tableval(val)

_make_table(table_info, rowlbl, title)

Attributes

_draw

_cdict

_Hcmap

_cdict

_Scmap

_template

pygsti.report.fogidiagram._draw
pygsti.report.fogidiagram._cdict
pygsti.report.fogidiagram._Hcmap
pygsti.report.fogidiagram._cdict
pygsti.report.fogidiagram._Scmap
pygsti.report.fogidiagram._create_errgen_op(vec, list_of_mxs)
pygsti.report.fogidiagram._is_dependent(infos_by_type)
pygsti.report.fogidiagram._dstr(d, joinstr='<br>')
pygsti.report.fogidiagram._fmt_tableval(val)
pygsti.report.fogidiagram._make_table(table_info, rowlbl, title)
class pygsti.report.fogidiagram.FOGIDiagram(fogi_stores, op_coefficients, model_dim, op_to_target_qubits=None, impact_mode='current')

Bases: object

A diagram of the first-order-gauge-invariant (FOGI) quantities of a model.

This class encapsulates a way of visualizing a model’s FOGI quantities.

_contrib(self, typ, op_set, infos_to_aggregate)
_extract_mag(self, d)

Extract the singe most important magnitude from a dictionary of contribution values such as those returned by _contrib(…)

_make_coherent_stochastic_by_support_table(self, op_set, infos_by_type)
_make_individual_fogi_table(self, op_set, infos_by_type)
_make_abbrev_table(self, op_set, infos_by_type)
_compute_by_weight_magnitudes(self, op_set, infos_by_type)
_compute_by_target_magnitudes(self, op_set, infos_by_type)
class pygsti.report.fogidiagram.FOGIGraphDiagram(fogi_stores, op_coefficients, model_dim, op_to_target_qubits=None, physics=True, numerical_labels=False, edge_threshold=1e-06, color_mode='separate', node_fontsize=20, edgenode_fontsize=14, edge_fontsize=12, impact_mode='current')

Bases: FOGIDiagram

A diagram of the first-order-gauge-invariant (FOGI) quantities of a model.

This class encapsulates a way of visualizing a model’s FOGI quantities.

_normalize(self, v)
_node_HScolor(self, Hvalue, Svalue)
_node_Hcolor(self, value)
_node_Scolor(self, value)
_color_to_textcolor(self, color_str)
_get_node_colors(self, coh, sto, total, compact=False, edge_node=False)
render(self, filename, initial_theta=0, custom_polar_positions=None, custom_polar_ranges=None)
class pygsti.report.fogidiagram.FOGISvgGraphDiagram(fogi_stores, op_coefficients, model_dim, op_to_target_qubits=None, physics=True, numerical_labels=False, edge_threshold=1e-06, color_mode='separate', node_fontsize=20, edgenode_fontsize=14, edge_fontsize=12, impact_mode='current')

Bases: FOGIGraphDiagram

A diagram of the first-order-gauge-invariant (FOGI) quantities of a model.

This class encapsulates a way of visualizing a model’s FOGI quantities.

_create_drawing(self)
_render_drawing(self, drawing, filename)
_draw_node(self, drawing, r, theta, coh, sto, op_label, total, val_max, groupid, info)
_draw_edge_node(self, drawing, x, y, coh, sto, total, val_max, op_set, info)
_draw_edge(self, drawing, x1, y1, x2, y2, edge_color, mag, val_max, edge_label, op_label, is_dependent)
_draw_wedge(self, drawing, r, theta_begin, theta_end, txt)
class pygsti.report.fogidiagram.FOGIVisNetworkGraphDiagram(fogi_stores, op_coefficients, model_dim, op_to_target_qubits=None, physics=True, numerical_labels=False, edge_threshold=1e-06, color_mode='separate', node_fontsize=20, edgenode_fontsize=14, edge_fontsize=12, impact_mode='current')

Bases: FOGIGraphDiagram

A diagram of the first-order-gauge-invariant (FOGI) quantities of a model.

This class encapsulates a way of visualizing a model’s FOGI quantities.

_create_drawing(self)
_render_drawing(self, drawing, filename)
_draw_node(self, drawing, r, theta, coh, sto, op_label, total, val_max, groupid, info)
_draw_edge_node(self, drawing, x, y, coh, sto, total, val_max, op_set, info)
_draw_edge(self, drawing, x1, y1, x2, y2, edge_color, mag, val_max, edge_label, op_label, is_dependent)
_draw_wedge(self, drawing, r, theta_begin, theta_end, txt)
class pygsti.report.fogidiagram.FOGIDetailTable(fogi_stores, op_coefficients, model_dim, op_to_target_qubits=None, mode='individual_terms', impact_mode='current')

Bases: FOGIDiagram

A diagram of the first-order-gauge-invariant (FOGI) quantities of a model.

This class encapsulates a way of visualizing a model’s FOGI quantities.

render(self, filename)
class pygsti.report.fogidiagram.FOGIMultiscaleGridDiagram(fogi_stores, op_coefficients, model_dim, op_to_target_qubits=None, impact_mode='current')

Bases: FOGIDiagram

A diagram of the first-order-gauge-invariant (FOGI) quantities of a model.

This class encapsulates a way of visualizing a model’s FOGI quantities.

render(self, detail_level=0, figsize=5, outfile=None, spacing=0.05, nudge=0.125, cell_fontsize=10, axes_fontsize=10, qty_key='bytarget')
class pygsti.report.fogidiagram.FOGIStackedBarDiagram(fogi_stores, op_coefficients, model_dim, op_to_target_qubits=None, impact_mode='current')

Bases: FOGIDiagram

A diagram of the first-order-gauge-invariant (FOGI) quantities of a model.

This class encapsulates a way of visualizing a model’s FOGI quantities.

render_svg(self, outfile=None, cell_fontsize=10, axes_fontsize=10, qty_key='bytarget')
pygsti.report.fogidiagram._template = Multiline-String
Show Value
  1<html>
  2<head>
  3    <!-- <link rel="stylesheet" href="pygsti_dataviz.css"> -->
  4    <!-- <script type="text/javascript" src="vis-network.js"></script> -->
  5    <!-- <script type="text/javascript" src="jquery-3.2.1.min.js"></script> -->
  6    <script type="text/javascript" src="vis-network.js"></script>
  7    <script type="text/javascript" src="jquery-3.2.1.min.js"></script>
  8    <!-- <script type="text/javascript"
  9                 src="https://unpkg.com/vis-network/standalone/umd/vis-network.min.js"></script> -->
 10    <!-- <script src="https://code.jquery.com/jquery-3.5.1.min.js"
 11                 integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script> -->
 12
 13    <style type="text/css">
 14      body {{
 15          //color: #d3d3d3;
 16          font: 12pt arial;
 17          //background-color: #222222;
 18      }}
 19
 20      #mynetwork {{
 21          width: 800px;
 22          height: 800px;
 23          border: 1px solid #444444;
 24          //background-color: #222222;
 25      }}
 26
 27      .invistable td {{
 28          vertical-align: top;
 29      }}
 30
 31      .infotable {{
 32          display: none;
 33      }}
 34
 35      .infotable table {{
 36          border-collapse: collapse;
 37      }}
 38
 39      .dataTable td, .dataTable th {{
 40         border: 2px solid #333;
 41         padding: 5px;
 42      }}
 43
 44      .dataTable {{
 45          font-family: "Computer Modern Serif","times new roman",serif;
 46          border-spacing: 0px;
 47          border-collapse: collapse;
 48          width: auto;
 49          margin: auto;
 50          margin-top: 5px;
 51          max-width: 100%;
 52          overflow: auto; /*hidden; - this hides content sometimes - needed?  */
 53      }}
 54
 55      .dataTable tbody tr td {{
 56          background-color: #ffffff;
 57          color: #262c31;
 58          font-family: "Computer Modern Serif","times new roman",serif;
 59          font-size: 10pt;
 60          text-align: center;
 61          vertical-align: middle;
 62      }}
 63
 64      .dataTable thead tr th,
 65      .dataTable tfoot tr td {{
 66          background-color: #333;
 67          color: #ffffff;
 68          font-size: 12px;
 69          font-weight: bold;
 70          text-align: center;
 71      }}
 72    </style>
 73</head>
 74<body>
 75<H2>FOGI Model Visualizer (experimental)</H2>
 76<table class="invistable">
 77<tr><td>
 78<div id="mynetwork"></div>
 79<!-- <pre id="eventSpan">TEST</pre> -->
 80</td><td>
 81<div id="tables">
 82{table_html}
 83</div>
 84<div id="longtables">
 85{long_table_html}
 86</div>
 87</td></tr></table>
 88
 89<script type="text/javascript">
 90var nodes = null;
 91var edges = null;
 92var network = null;
 93
 94function draw() {{
 95  // create people.
 96  // value corresponds with the age of the person
 97  nodes = new vis.DataSet([
 98{node_js}
 99  ]);
100
101  // create connections between people
102  // value corresponds with the amount of contact between two people
103  edges = new vis.DataSet([
104{edge_js}
105  ]);
106
107  // Instantiate our network object.
108  var container = document.getElementById("mynetwork");
109  var data = {{
110    nodes: nodes,
111    edges: edges,
112  }};
113  var options = {{
114      nodes: {{
115          shape: "box",
116          size: 30,
117          font: {{
118              multi: "html",
119              size: {node_fontsize},
120          }},
121          color: {{highlight: {{ background: "white", border: "black" }},
122                   hover: {{ background: "white", border: "black" }} }},
123          borderWidth: 3,
124      }},
125      edges: {{
126          smooth: false,
127          length: {springlength},
128          width: 2,
129          color: {{color: "gray", highlight: "black"}},
130          scaling: {{min: 6, max: 14, label: {{enabled: false}} }}, // was  4 -> 10
131          font: {{
132              size: {edge_fontsize},
133              color: "rgb(100, 100, 100)",
134          }},
135      }},
136      groups: {{
137          "relational": {{
138              shape: "dot",
139              size: 6,
140              color: "gray",
141          }}
142      }},
143      interaction: {{ hover: true, dragNodes: true, zoomView: false, dragView: true, multiselect: true  }},
144      manipulation: {{
145          enabled: false,
146      }},
147      physics: {{
148          enabled: {physics},
149          solver: "repulsion",
150          repulsion: {{nodeDistance: 100, springLength: {springlength}, springConstant: 0.05}},
151      }},
152  }};
153  network = new vis.Network(container, data, options);
154
155  //network.moveTo({{
156  //  position: {{x: 0, y: 0}},
157  //  offset: {{x: -800/2, y: -800/2}},
158  //  scale: 1,
159  //}});
160
161  network.on("click", function (params) {{
162    $(".infotable").hide()
163    for(var i = 0; i < params.nodes.length; i++) {{
164        $("#" + params.nodes[i]).show()
165    }}
166    //document.getElementById("eventSpan").innerHTML =
167    //  "<h2>Click event: node</h2>" + params.nodes;
168    //console.log(
169    //  "click event, getNodeAt returns: " + this.getNodeAt(params.pointer.DOM)
170    //);
171  }});
172
173  network.on("doubleClick", function (params) {{
174    $(".infotable").hide()
175    for(var i = 0; i < params.nodes.length; i++) {{
176        $("#" + params.nodes[i]).show()
177        $("#long" + params.nodes[i]).show()
178    }}
179  }});
180
181  network.on("beforeDrawing", function (ctx) {{
182    //ctx.strokeStyle = "#A6D5F7";
183    ctx.fillStyle = "#CCCCCC";
184    ctx.font = "20px Georgia";
185    ctx.textAlign = "center"
186    ctx.textBaseline = "middle";
187    {beforeDrawingCalls}
188  }});
189
190}}
191
192window.addEventListener("load", () => {{
193  draw();
194}});
195</script>
196</body>
197</html>