pyGSTi 0.9.12__cp310-cp310-win_amd64.whl → 0.9.13__cp310-cp310-win_amd64.whl
Sign up to get free protection for your applications and to get access to all the features.
- pyGSTi-0.9.13.dist-info/METADATA +197 -0
- {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/RECORD +211 -220
- {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/WHEEL +1 -1
- pygsti/_version.py +2 -2
- pygsti/algorithms/contract.py +1 -1
- pygsti/algorithms/core.py +62 -35
- pygsti/algorithms/fiducialpairreduction.py +95 -110
- pygsti/algorithms/fiducialselection.py +17 -8
- pygsti/algorithms/gaugeopt.py +2 -2
- pygsti/algorithms/germselection.py +87 -77
- pygsti/algorithms/mirroring.py +0 -388
- pygsti/algorithms/randomcircuit.py +165 -1333
- pygsti/algorithms/rbfit.py +0 -234
- pygsti/baseobjs/basis.py +94 -396
- pygsti/baseobjs/errorgenbasis.py +0 -132
- pygsti/baseobjs/errorgenspace.py +0 -10
- pygsti/baseobjs/label.py +52 -168
- pygsti/baseobjs/opcalc/fastopcalc.cp310-win_amd64.pyd +0 -0
- pygsti/baseobjs/opcalc/fastopcalc.pyx +2 -2
- pygsti/baseobjs/polynomial.py +13 -595
- pygsti/baseobjs/protectedarray.py +72 -132
- pygsti/baseobjs/statespace.py +1 -0
- pygsti/circuits/__init__.py +1 -1
- pygsti/circuits/circuit.py +753 -504
- pygsti/circuits/circuitconstruction.py +0 -4
- pygsti/circuits/circuitlist.py +47 -5
- pygsti/circuits/circuitparser/__init__.py +8 -8
- pygsti/circuits/circuitparser/fastcircuitparser.cp310-win_amd64.pyd +0 -0
- pygsti/circuits/circuitstructure.py +3 -3
- pygsti/circuits/cloudcircuitconstruction.py +27 -14
- pygsti/data/datacomparator.py +4 -9
- pygsti/data/dataset.py +51 -46
- pygsti/data/hypothesistest.py +0 -7
- pygsti/drivers/bootstrap.py +0 -49
- pygsti/drivers/longsequence.py +46 -10
- pygsti/evotypes/basereps_cython.cp310-win_amd64.pyd +0 -0
- pygsti/evotypes/chp/opreps.py +0 -61
- pygsti/evotypes/chp/statereps.py +0 -32
- pygsti/evotypes/densitymx/effectcreps.cpp +9 -10
- pygsti/evotypes/densitymx/effectreps.cp310-win_amd64.pyd +0 -0
- pygsti/evotypes/densitymx/effectreps.pyx +1 -1
- pygsti/evotypes/densitymx/opreps.cp310-win_amd64.pyd +0 -0
- pygsti/evotypes/densitymx/opreps.pyx +2 -2
- pygsti/evotypes/densitymx/statereps.cp310-win_amd64.pyd +0 -0
- pygsti/evotypes/densitymx/statereps.pyx +1 -1
- pygsti/evotypes/densitymx_slow/effectreps.py +7 -23
- pygsti/evotypes/densitymx_slow/opreps.py +16 -23
- pygsti/evotypes/densitymx_slow/statereps.py +10 -3
- pygsti/evotypes/evotype.py +39 -2
- pygsti/evotypes/stabilizer/effectreps.cp310-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/effectreps.pyx +0 -4
- pygsti/evotypes/stabilizer/opreps.cp310-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/opreps.pyx +0 -4
- pygsti/evotypes/stabilizer/statereps.cp310-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/statereps.pyx +1 -5
- pygsti/evotypes/stabilizer/termreps.cp310-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/termreps.pyx +0 -7
- pygsti/evotypes/stabilizer_slow/effectreps.py +0 -22
- pygsti/evotypes/stabilizer_slow/opreps.py +0 -4
- pygsti/evotypes/stabilizer_slow/statereps.py +0 -4
- pygsti/evotypes/statevec/effectreps.cp310-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/effectreps.pyx +1 -1
- pygsti/evotypes/statevec/opreps.cp310-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/opreps.pyx +2 -2
- pygsti/evotypes/statevec/statereps.cp310-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/statereps.pyx +1 -1
- pygsti/evotypes/statevec/termreps.cp310-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/termreps.pyx +0 -7
- pygsti/evotypes/statevec_slow/effectreps.py +0 -3
- pygsti/evotypes/statevec_slow/opreps.py +0 -5
- pygsti/extras/__init__.py +0 -1
- pygsti/extras/drift/signal.py +1 -1
- pygsti/extras/drift/stabilityanalyzer.py +3 -1
- pygsti/extras/interpygate/__init__.py +12 -0
- pygsti/extras/interpygate/core.py +0 -36
- pygsti/extras/interpygate/process_tomography.py +44 -10
- pygsti/extras/rpe/rpeconstruction.py +0 -2
- pygsti/forwardsims/__init__.py +1 -0
- pygsti/forwardsims/forwardsim.py +50 -93
- pygsti/forwardsims/mapforwardsim.py +78 -20
- pygsti/forwardsims/mapforwardsim_calc_densitymx.cp310-win_amd64.pyd +0 -0
- pygsti/forwardsims/mapforwardsim_calc_densitymx.pyx +65 -66
- pygsti/forwardsims/mapforwardsim_calc_generic.py +91 -13
- pygsti/forwardsims/matrixforwardsim.py +72 -17
- pygsti/forwardsims/termforwardsim.py +9 -111
- pygsti/forwardsims/termforwardsim_calc_stabilizer.cp310-win_amd64.pyd +0 -0
- pygsti/forwardsims/termforwardsim_calc_statevec.cp310-win_amd64.pyd +0 -0
- pygsti/forwardsims/termforwardsim_calc_statevec.pyx +0 -651
- pygsti/forwardsims/torchfwdsim.py +265 -0
- pygsti/forwardsims/weakforwardsim.py +2 -2
- pygsti/io/__init__.py +1 -2
- pygsti/io/mongodb.py +0 -2
- pygsti/io/stdinput.py +6 -22
- pygsti/layouts/copalayout.py +10 -12
- pygsti/layouts/distlayout.py +0 -40
- pygsti/layouts/maplayout.py +103 -25
- pygsti/layouts/matrixlayout.py +99 -60
- pygsti/layouts/prefixtable.py +1534 -52
- pygsti/layouts/termlayout.py +1 -1
- pygsti/modelmembers/instruments/instrument.py +3 -3
- pygsti/modelmembers/instruments/tpinstrument.py +2 -2
- pygsti/modelmembers/modelmember.py +0 -17
- pygsti/modelmembers/operations/__init__.py +3 -4
- pygsti/modelmembers/operations/affineshiftop.py +206 -0
- pygsti/modelmembers/operations/composederrorgen.py +1 -1
- pygsti/modelmembers/operations/composedop.py +1 -24
- pygsti/modelmembers/operations/denseop.py +5 -5
- pygsti/modelmembers/operations/eigpdenseop.py +2 -2
- pygsti/modelmembers/operations/embeddederrorgen.py +1 -1
- pygsti/modelmembers/operations/embeddedop.py +0 -1
- pygsti/modelmembers/operations/experrorgenop.py +5 -2
- pygsti/modelmembers/operations/fullarbitraryop.py +1 -0
- pygsti/modelmembers/operations/fullcptpop.py +2 -2
- pygsti/modelmembers/operations/fulltpop.py +28 -6
- pygsti/modelmembers/operations/fullunitaryop.py +5 -4
- pygsti/modelmembers/operations/lindbladcoefficients.py +93 -78
- pygsti/modelmembers/operations/lindbladerrorgen.py +268 -441
- pygsti/modelmembers/operations/linearop.py +7 -27
- pygsti/modelmembers/operations/opfactory.py +1 -1
- pygsti/modelmembers/operations/repeatedop.py +1 -24
- pygsti/modelmembers/operations/staticstdop.py +1 -1
- pygsti/modelmembers/povms/__init__.py +3 -3
- pygsti/modelmembers/povms/basepovm.py +7 -36
- pygsti/modelmembers/povms/complementeffect.py +4 -9
- pygsti/modelmembers/povms/composedeffect.py +0 -320
- pygsti/modelmembers/povms/computationaleffect.py +1 -1
- pygsti/modelmembers/povms/computationalpovm.py +3 -1
- pygsti/modelmembers/povms/effect.py +3 -5
- pygsti/modelmembers/povms/marginalizedpovm.py +3 -81
- pygsti/modelmembers/povms/tppovm.py +74 -2
- pygsti/modelmembers/states/__init__.py +2 -5
- pygsti/modelmembers/states/composedstate.py +0 -317
- pygsti/modelmembers/states/computationalstate.py +3 -3
- pygsti/modelmembers/states/cptpstate.py +4 -4
- pygsti/modelmembers/states/densestate.py +10 -8
- pygsti/modelmembers/states/fullpurestate.py +0 -24
- pygsti/modelmembers/states/purestate.py +1 -1
- pygsti/modelmembers/states/state.py +5 -6
- pygsti/modelmembers/states/tpstate.py +28 -10
- pygsti/modelmembers/term.py +3 -6
- pygsti/modelmembers/torchable.py +50 -0
- pygsti/modelpacks/_modelpack.py +1 -1
- pygsti/modelpacks/smq1Q_ZN.py +3 -1
- pygsti/modelpacks/smq2Q_XXYYII.py +2 -1
- pygsti/modelpacks/smq2Q_XY.py +3 -3
- pygsti/modelpacks/smq2Q_XYI.py +2 -2
- pygsti/modelpacks/smq2Q_XYICNOT.py +3 -3
- pygsti/modelpacks/smq2Q_XYICPHASE.py +3 -3
- pygsti/modelpacks/smq2Q_XYXX.py +1 -1
- pygsti/modelpacks/smq2Q_XYZICNOT.py +3 -3
- pygsti/modelpacks/smq2Q_XYZZ.py +1 -1
- pygsti/modelpacks/stdtarget.py +0 -121
- pygsti/models/cloudnoisemodel.py +1 -2
- pygsti/models/explicitcalc.py +3 -3
- pygsti/models/explicitmodel.py +3 -13
- pygsti/models/fogistore.py +5 -3
- pygsti/models/localnoisemodel.py +1 -2
- pygsti/models/memberdict.py +0 -12
- pygsti/models/model.py +801 -68
- pygsti/models/modelconstruction.py +4 -4
- pygsti/models/modelnoise.py +2 -2
- pygsti/models/modelparaminterposer.py +1 -1
- pygsti/models/oplessmodel.py +1 -1
- pygsti/models/qutrit.py +15 -14
- pygsti/objectivefns/objectivefns.py +75 -140
- pygsti/objectivefns/wildcardbudget.py +2 -7
- pygsti/optimize/__init__.py +1 -0
- pygsti/optimize/arraysinterface.py +28 -0
- pygsti/optimize/customcg.py +0 -12
- pygsti/optimize/customlm.py +129 -323
- pygsti/optimize/customsolve.py +2 -2
- pygsti/optimize/optimize.py +0 -84
- pygsti/optimize/simplerlm.py +841 -0
- pygsti/optimize/wildcardopt.py +19 -598
- pygsti/protocols/confidenceregionfactory.py +28 -14
- pygsti/protocols/estimate.py +31 -14
- pygsti/protocols/gst.py +238 -142
- pygsti/protocols/modeltest.py +19 -12
- pygsti/protocols/protocol.py +9 -37
- pygsti/protocols/rb.py +450 -79
- pygsti/protocols/treenode.py +8 -2
- pygsti/protocols/vb.py +108 -206
- pygsti/protocols/vbdataframe.py +1 -1
- pygsti/report/factory.py +0 -15
- pygsti/report/fogidiagram.py +1 -17
- pygsti/report/modelfunction.py +12 -3
- pygsti/report/mpl_colormaps.py +1 -1
- pygsti/report/plothelpers.py +11 -3
- pygsti/report/report.py +16 -0
- pygsti/report/reportables.py +41 -37
- pygsti/report/templates/offline/pygsti_dashboard.css +6 -0
- pygsti/report/templates/offline/pygsti_dashboard.js +12 -0
- pygsti/report/workspace.py +2 -14
- pygsti/report/workspaceplots.py +328 -505
- pygsti/tools/basistools.py +9 -36
- pygsti/tools/edesigntools.py +124 -96
- pygsti/tools/fastcalc.cp310-win_amd64.pyd +0 -0
- pygsti/tools/fastcalc.pyx +35 -81
- pygsti/tools/internalgates.py +151 -15
- pygsti/tools/jamiolkowski.py +5 -5
- pygsti/tools/lindbladtools.py +19 -11
- pygsti/tools/listtools.py +0 -114
- pygsti/tools/matrixmod2.py +1 -1
- pygsti/tools/matrixtools.py +173 -339
- pygsti/tools/nameddict.py +1 -1
- pygsti/tools/optools.py +154 -88
- pygsti/tools/pdftools.py +0 -25
- pygsti/tools/rbtheory.py +3 -320
- pygsti/tools/slicetools.py +64 -12
- pyGSTi-0.9.12.dist-info/METADATA +0 -157
- pygsti/algorithms/directx.py +0 -711
- pygsti/evotypes/qibo/__init__.py +0 -33
- pygsti/evotypes/qibo/effectreps.py +0 -78
- pygsti/evotypes/qibo/opreps.py +0 -376
- pygsti/evotypes/qibo/povmreps.py +0 -98
- pygsti/evotypes/qibo/statereps.py +0 -174
- pygsti/extras/rb/__init__.py +0 -13
- pygsti/extras/rb/benchmarker.py +0 -957
- pygsti/extras/rb/dataset.py +0 -378
- pygsti/extras/rb/io.py +0 -814
- pygsti/extras/rb/simulate.py +0 -1020
- pygsti/io/legacyio.py +0 -385
- pygsti/modelmembers/povms/denseeffect.py +0 -142
- {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/LICENSE +0 -0
- {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/top_level.txt +0 -0
@@ -183,10 +183,6 @@ def repeat_with_max_length(x, max_length, assert_at_least_one_rep=False):
|
|
183
183
|
"""
|
184
184
|
return repeat(x, repeat_count_with_max_length(x, max_length, assert_at_least_one_rep), assert_at_least_one_rep)
|
185
185
|
|
186
|
-
#Useful for anything?
|
187
|
-
#def repeat_empty(x,max_length,assert_at_least_one_rep=False):
|
188
|
-
# return ()
|
189
|
-
|
190
186
|
|
191
187
|
def repeat_and_truncate(x, n, assert_at_least_one_rep=False):
|
192
188
|
"""
|
pygsti/circuits/circuitlist.py
CHANGED
@@ -158,11 +158,7 @@ class CircuitList(_NicelySerializable):
|
|
158
158
|
-------
|
159
159
|
CircuitList
|
160
160
|
"""
|
161
|
-
|
162
|
-
new_circuits = list(filter(lambda c: c in circuits_to_keep, self._circuits))
|
163
|
-
else:
|
164
|
-
current_circuits = set(self._circuits)
|
165
|
-
new_circuits = list(filter(lambda c: c in current_circuits, circuits_to_keep))
|
161
|
+
new_circuits = list(filter(lambda c: c in set(circuits_to_keep), self._circuits))
|
166
162
|
return CircuitList(new_circuits, self.op_label_aliases) # don't transfer weights or name
|
167
163
|
|
168
164
|
def truncate_to_dataset(self, dataset):
|
@@ -205,3 +201,49 @@ class CircuitList(_NicelySerializable):
|
|
205
201
|
self.__dict__.update(state_dict)
|
206
202
|
if 'uuid' not in state_dict: # backward compatibility
|
207
203
|
self.uuid = _uuid.uuid4() # create a new uuid
|
204
|
+
|
205
|
+
def elementvec_to_array(self, elementvec, layout, mergeop="sum"):
|
206
|
+
"""
|
207
|
+
Form an array of values corresponding to this CircuitList from an element vector.
|
208
|
+
|
209
|
+
An element vector holds individual-outcome elements (e.g. the bulk probabilities
|
210
|
+
computed by a model).
|
211
|
+
|
212
|
+
Parameters
|
213
|
+
----------
|
214
|
+
elementvec : numpy array
|
215
|
+
An array containting the values to use when constructing a
|
216
|
+
matrix of values for this CircuitList. This array may contain more
|
217
|
+
values than are needed by this CircuitList. Indices into this array
|
218
|
+
are given by `elindices_lookup`.
|
219
|
+
|
220
|
+
layout : CircuitOutcomeProbabilityArrayLayout
|
221
|
+
The layout of `elementvec`, giving the mapping between its elements and
|
222
|
+
circuit outcomes.
|
223
|
+
|
224
|
+
mergeop : "sum" or format string, optional
|
225
|
+
Dictates how to combine the `elementvec` components corresponding to a single
|
226
|
+
plaquette entry (circuit). If "sum", the returned array contains summed
|
227
|
+
values. If a format string, e.g. `"%.2f"`, then the so-formatted components
|
228
|
+
are joined together with separating commas, and the resulting array contains
|
229
|
+
string (object-type) entries.
|
230
|
+
|
231
|
+
Returns
|
232
|
+
-------
|
233
|
+
numpy array
|
234
|
+
"""
|
235
|
+
|
236
|
+
if mergeop == "sum":
|
237
|
+
ret = _np.nan * _np.ones(len(self), 'd')
|
238
|
+
for i,ckt in enumerate(self._circuits):
|
239
|
+
ret[i] = sum(elementvec[layout.indices(ckt)])
|
240
|
+
elif '%' in mergeop:
|
241
|
+
fmt = mergeop
|
242
|
+
ret = _np.nan * _np.ones(len(self), dtype=_np.object_)
|
243
|
+
for i,ckt in enumerate(self._circuits):
|
244
|
+
ret[i] = ", ".join(["NaN" if _np.isnan(x) else
|
245
|
+
(fmt % x) for x in elementvec[layout.indices(ckt)]])
|
246
|
+
else:
|
247
|
+
raise ValueError("Invalid `mergeop` arg: %s" % str(mergeop))
|
248
|
+
|
249
|
+
return ret
|
@@ -116,7 +116,7 @@ class CircuitLexer:
|
|
116
116
|
|
117
117
|
@staticmethod
|
118
118
|
def t_GATE(t): # noqa
|
119
|
-
"""
|
119
|
+
r"""
|
120
120
|
``'G[a-z0-9_]+(;[a-zQ0-9_\./]+)*(:[a-zQ0-9_]+)*(![0-9\.]+)?'``
|
121
121
|
"""
|
122
122
|
|
@@ -128,7 +128,7 @@ class CircuitLexer:
|
|
128
128
|
|
129
129
|
@staticmethod
|
130
130
|
def t_INSTRMT(t): # noqa
|
131
|
-
"""
|
131
|
+
r"""
|
132
132
|
``'I[a-z0-9_]+(![0-9\.]+)?'``
|
133
133
|
"""
|
134
134
|
#Note: don't need to convert parts[1],etc, to integers (if possible) as Label automatically does this
|
@@ -138,7 +138,7 @@ class CircuitLexer:
|
|
138
138
|
|
139
139
|
@staticmethod
|
140
140
|
def t_PREP(t): # noqa
|
141
|
-
"""
|
141
|
+
r"""
|
142
142
|
``'rho[a-z0-9_]+(![0-9\.]+)?'``
|
143
143
|
"""
|
144
144
|
#Note: don't need to convert parts[1],etc, to integers (if possible) as Label automatically does this
|
@@ -148,7 +148,7 @@ class CircuitLexer:
|
|
148
148
|
|
149
149
|
@staticmethod
|
150
150
|
def t_POVM(t): # noqa
|
151
|
-
"""
|
151
|
+
r"""
|
152
152
|
``'M[a-z0-9_]+(![0-9\.]+)?'``
|
153
153
|
"""
|
154
154
|
#Note: don't need to convert parts[1],etc, to integers (if possible) as Label automatically does this
|
@@ -158,14 +158,14 @@ class CircuitLexer:
|
|
158
158
|
|
159
159
|
@staticmethod
|
160
160
|
def t_STRINGIND(t): # noqa
|
161
|
-
"""
|
161
|
+
r"""
|
162
162
|
``'S(?=\s*\<)'``
|
163
163
|
"""
|
164
164
|
return t
|
165
165
|
|
166
166
|
@staticmethod
|
167
167
|
def t_REFLBL(t): # noqa
|
168
|
-
"""
|
168
|
+
r"""
|
169
169
|
``'<\s*[a-zA-Z0-9_]+\s*>'``
|
170
170
|
"""
|
171
171
|
t.value = t.value[1:-1].strip()
|
@@ -184,7 +184,7 @@ class CircuitLexer:
|
|
184
184
|
|
185
185
|
@staticmethod
|
186
186
|
def t_NOP(t): # noqa
|
187
|
-
"""
|
187
|
+
r"""
|
188
188
|
``'\{\}'``
|
189
189
|
"""
|
190
190
|
t.value = tuple()
|
@@ -192,7 +192,7 @@ class CircuitLexer:
|
|
192
192
|
|
193
193
|
@staticmethod
|
194
194
|
def t_INTEGER(t): # noqa
|
195
|
-
"""
|
195
|
+
r"""
|
196
196
|
``'\d+'``
|
197
197
|
"""
|
198
198
|
t.value = int(t.value)
|
Binary file
|
@@ -117,9 +117,9 @@ class CircuitPlaquette(_NicelySerializable):
|
|
117
117
|
def __len__(self):
|
118
118
|
return len(self.elements)
|
119
119
|
|
120
|
-
def
|
120
|
+
def elementvec_to_array(self, elementvec, layout, mergeop="sum"):
|
121
121
|
"""
|
122
|
-
Form a
|
122
|
+
Form a array of values corresponding to this plaquette from an element vector.
|
123
123
|
|
124
124
|
An element vector holds individual-outcome elements (e.g. the bulk probabilities
|
125
125
|
computed by a model).
|
@@ -644,7 +644,7 @@ class PlaquetteGridCircuitStructure(_CircuitList):
|
|
644
644
|
else:
|
645
645
|
op_label_aliases = weights_dict = name = None
|
646
646
|
|
647
|
-
return cls({}, [], [], circuits_or_structure,
|
647
|
+
return cls({}, [], [], '', '', circuits_or_structure,
|
648
648
|
op_label_aliases, weights_dict, name)
|
649
649
|
|
650
650
|
def __init__(self, plaquettes, x_values, y_values, xlabel, ylabel, additional_circuits=None, op_label_aliases=None,
|
@@ -261,9 +261,12 @@ def _find_amped_polynomials_for_syntheticidle(qubit_filter, idle_str, model, sin
|
|
261
261
|
#print("DB: Rank %d: running itr=%d" % (comm.Get_rank(), itr))
|
262
262
|
|
263
263
|
printer.show_progress(loc_itr - 1, nLocIters, prefix='--- Finding amped-polys for idle: ')
|
264
|
-
|
264
|
+
|
265
265
|
for i, el in enumerate(prep):
|
266
|
-
|
266
|
+
if i==0:
|
267
|
+
prepFid = _onqubit(el, qubit_filter[i])
|
268
|
+
else:
|
269
|
+
prepFid = prepFid + _onqubit(el, qubit_filter[i])
|
267
270
|
|
268
271
|
for meas in _itertools.product(*([single_q_meas_fiducials] * nQubits)):
|
269
272
|
|
@@ -278,9 +281,11 @@ def _find_amped_polynomials_for_syntheticidle(qubit_filter, idle_str, model, sin
|
|
278
281
|
# if all are not the same or all are not different, skip
|
279
282
|
if not (all(cmp) or not any(cmp)): continue
|
280
283
|
|
281
|
-
measFid = _Circuit((), line_labels=idle_str.line_labels)
|
282
284
|
for i, el in enumerate(meas):
|
283
|
-
|
285
|
+
if i==0:
|
286
|
+
measFid = _onqubit(el, qubit_filter[i])
|
287
|
+
else:
|
288
|
+
measFid = measFid + _onqubit(el, qubit_filter[i])
|
284
289
|
|
285
290
|
gatename_fidpair_list = [(prep[i], meas[i]) for i in range(nQubits)]
|
286
291
|
if gatename_fidpair_list in selected_gatename_fidpair_lists:
|
@@ -673,9 +678,11 @@ def _find_amped_polynomials_for_clifford_syntheticidle(qubit_filter, core_filter
|
|
673
678
|
# prep[ qubit_filter.index(core_ql) ] = prep_core[i]
|
674
679
|
# prep = tuple(prep)
|
675
680
|
|
676
|
-
prepFid = _Circuit(())
|
677
681
|
for i, el in enumerate(prep):
|
678
|
-
|
682
|
+
if i==0:
|
683
|
+
prepFid = _onqubit(el, qubit_filter[i])
|
684
|
+
else:
|
685
|
+
prepFid = prepFid + _onqubit(el, qubit_filter[i])
|
679
686
|
|
680
687
|
#OLD: back when we tried iterating over *all* core fiducial pairs
|
681
688
|
# (now we think/know this is unnecessary - the "true idle" fidpairs suffice)
|
@@ -687,9 +694,11 @@ def _find_amped_polynomials_for_clifford_syntheticidle(qubit_filter, core_filter
|
|
687
694
|
# # meas[ qubit_filter.index(core_ql) ] = meas_core[i]
|
688
695
|
# meas = tuple(meas)
|
689
696
|
|
690
|
-
measFid = _Circuit(())
|
691
697
|
for i, el in enumerate(meas):
|
692
|
-
|
698
|
+
if i==0:
|
699
|
+
measFid = _onqubit(el, qubit_filter[i])
|
700
|
+
else:
|
701
|
+
measFid = measFid + _onqubit(el, qubit_filter[i])
|
693
702
|
|
694
703
|
#print("PREPMEAS = ",prepFid,measFid)
|
695
704
|
|
@@ -891,9 +900,11 @@ def _get_fidpairs_needed_to_access_amped_polynomials(qubit_filter, core_filter,
|
|
891
900
|
prep[qubit_filter.index(core_ql)] = prep_core[i]
|
892
901
|
prep = tuple(prep)
|
893
902
|
|
894
|
-
prepFid = _Circuit(())
|
895
903
|
for i, el in enumerate(prep):
|
896
|
-
|
904
|
+
if i==0:
|
905
|
+
prepFid = _onqubit(el, qubit_filter[i])
|
906
|
+
else:
|
907
|
+
prepFid = prepFid + _onqubit(el, qubit_filter[i])
|
897
908
|
|
898
909
|
#for meas in _itertools.product(*([single_q_fiducials]*nQubits) ):
|
899
910
|
#for meas_core in _itertools.product(*([single_q_fiducials]*nCore) ):
|
@@ -908,9 +919,11 @@ def _get_fidpairs_needed_to_access_amped_polynomials(qubit_filter, core_filter,
|
|
908
919
|
meas[qubit_filter.index(core_ql)] = meas_core[i]
|
909
920
|
meas = tuple(meas)
|
910
921
|
|
911
|
-
measFid = _Circuit(())
|
912
922
|
for i, el in enumerate(meas):
|
913
|
-
|
923
|
+
if i==0:
|
924
|
+
measFid = _onqubit(el, qubit_filter[i])
|
925
|
+
else:
|
926
|
+
measFid = measFid + _onqubit(el, qubit_filter[i])
|
914
927
|
#print("CONSIDER: ",prep,"-",meas)
|
915
928
|
|
916
929
|
opstr = prepFid + germ_power_str + measFid # should be a Circuit
|
@@ -1324,7 +1337,7 @@ def _get_candidates_for_core(model, core_qubits, candidate_counts, seed_start):
|
|
1324
1337
|
return candidate_germs
|
1325
1338
|
|
1326
1339
|
|
1327
|
-
@_deprecated_fn("Use pygsti.circuits.
|
1340
|
+
@_deprecated_fn("Use pygsti.circuits.create_cloudnoise_circuits(...).")
|
1328
1341
|
def _create_xycnot_cloudnoise_circuits(num_qubits, max_lengths, geometry, cnot_edges, max_idle_weight=1, maxhops=0,
|
1329
1342
|
extra_weight_1_hops=0, extra_gate_weight=0, parameterization="H+S",
|
1330
1343
|
verbosity=0, cache=None, idle_only=False,
|
@@ -2151,7 +2164,7 @@ def _get_kcoverage_template_k2(n):
|
|
2151
2164
|
def invert(bstr):
|
2152
2165
|
return [(0 if x else 1) for x in bstr]
|
2153
2166
|
|
2154
|
-
half = [bitstr(n, k) for k in range(int(_np.ceil(_np.
|
2167
|
+
half = [bitstr(n, k) for k in range(int(_np.ceil(_np.log2(n))))]
|
2155
2168
|
other_half = [invert(bstr) for bstr in half]
|
2156
2169
|
return half + other_half
|
2157
2170
|
|
pygsti/data/datacomparator.py
CHANGED
@@ -49,11 +49,6 @@ def _loglikelihood(p_list, n_list):
|
|
49
49
|
output += _xlogy(n_list[i], pVal)
|
50
50
|
return output
|
51
51
|
|
52
|
-
# Only used by the rectify data function, which is commented out,
|
53
|
-
# so this is also commented out.
|
54
|
-
# def loglikelihoodRatioObj(alpha,n_list_list,dof):
|
55
|
-
# return _np.abs(dof - _loglikelihood_ratio(alpha*n_list_list))
|
56
|
-
|
57
52
|
|
58
53
|
def _loglikelihood_ratio(n_list_list):
|
59
54
|
"""
|
@@ -75,11 +70,11 @@ def _loglikelihood_ratio(n_list_list):
|
|
75
70
|
The log-likehood ratio for this model comparison.
|
76
71
|
"""
|
77
72
|
nListC = _np.sum(n_list_list, axis=0)
|
78
|
-
pListC = nListC / _np.
|
73
|
+
pListC = nListC / _np.float64(_np.sum(nListC))
|
79
74
|
lC = _loglikelihood(pListC, nListC)
|
80
75
|
li_list = []
|
81
76
|
for nList in n_list_list:
|
82
|
-
pList = _np.array(nList) / _np.
|
77
|
+
pList = _np.array(nList) / _np.float64(_np.sum(nList))
|
83
78
|
li_list.append(_loglikelihood(pList, nList))
|
84
79
|
lS = _np.sum(li_list)
|
85
80
|
return -2 * (lC - lS)
|
@@ -647,9 +642,9 @@ class DataComparator():
|
|
647
642
|
if self.inconsistent_datasets_detected:
|
648
643
|
print("The data are INCONSISTENT at {0:.2f}% significance.".format(self.significance * 100))
|
649
644
|
print(" - Details:")
|
650
|
-
print(" - The aggregate log-
|
645
|
+
print(" - The aggregate log-likelihood ratio test is "
|
651
646
|
"significant at {0:.2f} standard deviations.".format(self._aggregate_nsigma))
|
652
|
-
print(" - The aggregate log-
|
647
|
+
print(" - The aggregate log-likelihood ratio test "
|
653
648
|
"standard deviations signficance threshold is {0:.2f}".format(self._aggregate_nsigma_threshold))
|
654
649
|
print(
|
655
650
|
" - The number of sequences with data that is "
|
pygsti/data/dataset.py
CHANGED
@@ -11,6 +11,7 @@ Defines the DataSet class and supporting classes and functions
|
|
11
11
|
#***************************************************************************************************
|
12
12
|
|
13
13
|
import bisect as _bisect
|
14
|
+
from collections.abc import Iterable as _Iterable
|
14
15
|
import copy as _copy
|
15
16
|
import itertools as _itertools
|
16
17
|
import numbers as _numbers
|
@@ -295,34 +296,10 @@ class _DataSetRow(object):
|
|
295
296
|
last_time = None
|
296
297
|
seriesDict = {self.dataset.olIndex[ol]: [] for ol in self.dataset.outcome_labels}
|
297
298
|
|
298
|
-
#REMOVED: (though this gives slightly different behavior)
|
299
|
-
#for outcome_label in self.outcomes:
|
300
|
-
# if outcome_label not in seriesDict.keys():
|
301
|
-
# seriesDict[outcome_label] = []
|
302
|
-
|
303
299
|
if self.reps is None:
|
304
300
|
reps = _np.ones(len(self.time), _np.int64)
|
305
301
|
else: reps = self.reps
|
306
302
|
|
307
|
-
# An alternate implementation that appears to be (surprisingly?) slower...
|
308
|
-
##Get time bin locations
|
309
|
-
#time_bins_borders = []
|
310
|
-
#last_time = None
|
311
|
-
#for i, t in enumerate(self.time):
|
312
|
-
# if t != last_time:
|
313
|
-
# time_bins_borders.append(i)
|
314
|
-
# last_time = t
|
315
|
-
#time_bins_borders.append(len(self.time))
|
316
|
-
#nTimes = len(time_bins_borders) - 1
|
317
|
-
#
|
318
|
-
#seriesDict = {self.dataset.olIndex[ol]: _np.zeros(nTimes, _np.int64) for ol in self.dataset.outcome_labels}
|
319
|
-
#
|
320
|
-
#for i in range(nTimes):
|
321
|
-
# slc = slice(time_bins_borders[i],time_bins_borders[i+1])
|
322
|
-
# times.append( self.time[slc.start] )
|
323
|
-
# for oli, rep in zip(self.oli[slc], reps[slc]):
|
324
|
-
# seriesDict[oli][i] += rep
|
325
|
-
|
326
303
|
for t, oli, rep in zip(self.time, self.oli, reps):
|
327
304
|
|
328
305
|
if t != last_time:
|
@@ -585,26 +562,28 @@ class _DataSetRow(object):
|
|
585
562
|
tslc = _np.where(_np.isclose(self.time, timestamp))[0]
|
586
563
|
else: tslc = slice(None)
|
587
564
|
|
565
|
+
oli_tslc = self.oli[tslc]
|
588
566
|
nOutcomes = len(self.dataset.olIndex)
|
589
|
-
nIndices = len(
|
567
|
+
nIndices = len(oli_tslc)
|
568
|
+
|
590
569
|
if nOutcomes <= nIndices or all_outcomes:
|
591
570
|
if self.reps is None:
|
592
571
|
for ol, i in self.dataset.olIndex.items():
|
593
|
-
cnt = float(_np.count_nonzero(_np.equal(
|
594
|
-
if
|
572
|
+
cnt = float(_np.count_nonzero(_np.equal(oli_tslc, i)))
|
573
|
+
if cnt > 0 or all_outcomes:
|
595
574
|
cntDict.setitem_unsafe(ol, cnt)
|
596
575
|
else:
|
597
576
|
for ol, i in self.dataset.olIndex.items():
|
598
|
-
inds =
|
599
|
-
if
|
577
|
+
inds = oli_tslc[oli_tslc == i]
|
578
|
+
if len(inds) > 0 or all_outcomes:
|
600
579
|
cntDict.setitem_unsafe(ol, float(sum(self.reps[tslc][inds])))
|
601
580
|
else:
|
602
581
|
if self.reps is None:
|
603
|
-
for ol_index in
|
582
|
+
for ol_index in oli_tslc:
|
604
583
|
ol = self.dataset.ol[ol_index]
|
605
584
|
cntDict.setitem_unsafe(ol, 1.0 + cntDict.getitem_unsafe(ol, 0.0))
|
606
585
|
else:
|
607
|
-
for ol_index, reps in zip(
|
586
|
+
for ol_index, reps in zip(oli_tslc, self.reps[tslc]):
|
608
587
|
ol = self.dataset.ol[ol_index]
|
609
588
|
cntDict.setitem_unsafe(ol, reps + cntDict.getitem_unsafe(ol, 0.0))
|
610
589
|
|
@@ -615,7 +594,8 @@ class _DataSetRow(object):
|
|
615
594
|
"""
|
616
595
|
Dictionary of per-outcome counts.
|
617
596
|
"""
|
618
|
-
if self._cntcache:
|
597
|
+
if self._cntcache:
|
598
|
+
return self._cntcache # if not None *and* len > 0
|
619
599
|
ret = self._get_counts()
|
620
600
|
if self._cntcache is not None: # == and empty dict {}
|
621
601
|
self._cntcache.update(ret)
|
@@ -1031,12 +1011,13 @@ class DataSet(_MongoSerializable):
|
|
1031
1011
|
self.olIndex = outcome_label_indices
|
1032
1012
|
self.olIndex_max = max(self.olIndex.values()) if len(self.olIndex) > 0 else -1
|
1033
1013
|
elif outcome_labels is not None:
|
1034
|
-
if isinstance(outcome_labels,
|
1035
|
-
nqubits = outcome_labels
|
1036
|
-
tup_outcomeLabels = [("".join(x),) for x in _itertools.product(*([('0', '1')] * nqubits))]
|
1037
|
-
else:
|
1014
|
+
if isinstance(outcome_labels, _Iterable):
|
1038
1015
|
tup_outcomeLabels = [_ld.OutcomeLabelDict.to_outcome(ol)
|
1039
1016
|
for ol in outcome_labels] # strings -> tuple outcome labels
|
1017
|
+
else: # Given an int which signifies how many qubits
|
1018
|
+
nqubits = outcome_labels
|
1019
|
+
tup_outcomeLabels = [("".join(x),) for x in _itertools.product(*([('0', '1')] * nqubits))]
|
1020
|
+
|
1040
1021
|
self.olIndex = _OrderedDict([(ol, i) for (i, ol) in enumerate(tup_outcomeLabels)])
|
1041
1022
|
self.olIndex_max = len(tup_outcomeLabels) - 1
|
1042
1023
|
else:
|
@@ -1197,10 +1178,10 @@ class DataSet(_MongoSerializable):
|
|
1197
1178
|
circuit = _cir.Circuit.cast(circuit)
|
1198
1179
|
|
1199
1180
|
#Note: cirIndex value is either an int (non-static) or a slice (static)
|
1200
|
-
|
1201
|
-
|
1202
|
-
return _DataSetRow(self, self.oliData[
|
1203
|
-
self.timeData[
|
1181
|
+
cirIndex = self.cirIndex[circuit]
|
1182
|
+
repData = self.repData[cirIndex] if (self.repData is not None) else None
|
1183
|
+
return _DataSetRow(self, self.oliData[cirIndex],
|
1184
|
+
self.timeData[cirIndex], repData,
|
1204
1185
|
self.cnt_cache[circuit] if self.bStatic else None,
|
1205
1186
|
self.auxInfo[circuit])
|
1206
1187
|
|
@@ -1413,17 +1394,19 @@ class DataSet(_MongoSerializable):
|
|
1413
1394
|
# if "keepseparate" mode, set occurrence id existing circuits to next available (positive) integer.
|
1414
1395
|
if self.collisionAction == "keepseparate":
|
1415
1396
|
if circuit in self.cirIndex:
|
1416
|
-
tagged_circuit = circuit.copy()
|
1397
|
+
tagged_circuit = circuit.copy(editable=True)
|
1417
1398
|
i = 1; tagged_circuit.occurrence = i
|
1418
1399
|
while tagged_circuit in self.cirIndex:
|
1419
1400
|
i += 1; tagged_circuit.occurrence = i
|
1401
|
+
tagged_circuit.done_editing()
|
1420
1402
|
#add data for a new (duplicate) circuit
|
1421
1403
|
circuit = tagged_circuit
|
1422
1404
|
|
1423
1405
|
# in other modes ("overwrite" and "aggregate"), strip off occurrence so duplicates are acted on appropriately
|
1424
1406
|
elif circuit.occurrence is not None:
|
1425
|
-
stripped_circuit = circuit.copy()
|
1407
|
+
stripped_circuit = circuit.copy(editable=True)
|
1426
1408
|
stripped_circuit.occurrence = None
|
1409
|
+
stripped_circuit.done_editing()
|
1427
1410
|
circuit = stripped_circuit
|
1428
1411
|
|
1429
1412
|
return circuit
|
@@ -1601,7 +1584,7 @@ class DataSet(_MongoSerializable):
|
|
1601
1584
|
self._add_raw_arrays(circuit, outcome_index_array, time_array, count_array,
|
1602
1585
|
overwriteExisting, record_zero_counts, aux)
|
1603
1586
|
|
1604
|
-
def add_cirq_trial_result(self, circuit, trial_result, key):
|
1587
|
+
def add_cirq_trial_result(self, circuit, trial_result, key, convert_int_to_binary = True, num_qubits = None):
|
1605
1588
|
"""
|
1606
1589
|
Add a single circuit's counts --- stored in a Cirq TrialResult --- to this DataSet
|
1607
1590
|
|
@@ -1617,6 +1600,16 @@ class DataSet(_MongoSerializable):
|
|
1617
1600
|
key : str
|
1618
1601
|
The string key of the measurement. Set by cirq.measure.
|
1619
1602
|
|
1603
|
+
convert_int_to_binary : bool, optional (defaut True)
|
1604
|
+
By default the keys in the cirq Results object are the integers representing
|
1605
|
+
the bitstrings of the measurements on a set of qubits, in big-endian convention.
|
1606
|
+
If True this converts back to a binary string before adding the counts as a
|
1607
|
+
entry into the pygsti dataset.
|
1608
|
+
|
1609
|
+
num_qubits : int, optional (default None)
|
1610
|
+
Number of qubits used in the conversion from integers to binary when convert_int_to_binary
|
1611
|
+
is True. If None, then the number of line_labels on the input circuit is used.
|
1612
|
+
|
1620
1613
|
Returns
|
1621
1614
|
-------
|
1622
1615
|
None
|
@@ -1629,8 +1622,17 @@ class DataSet(_MongoSerializable):
|
|
1629
1622
|
|
1630
1623
|
# TrialResult.histogram returns a collections.Counter object, which is a subclass of dict.
|
1631
1624
|
histogram_counter = trial_result.histogram(key=key)
|
1625
|
+
|
1626
|
+
if num_qubits is None:
|
1627
|
+
num_qubits = len(circuit.line_labels)
|
1628
|
+
|
1632
1629
|
# The keys in histogram_counter are integers, but pyGSTi likes dictionary keys to be strings.
|
1633
|
-
count_dict = {
|
1630
|
+
count_dict = {}
|
1631
|
+
for key, value in histogram_counter.items():
|
1632
|
+
if convert_int_to_binary:
|
1633
|
+
count_dict[_np.binary_repr(key, width= num_qubits)] = value
|
1634
|
+
else:
|
1635
|
+
count_dict[str(key)] = value
|
1634
1636
|
self.add_count_dict(circuit, count_dict)
|
1635
1637
|
|
1636
1638
|
def add_raw_series_data(self, circuit, outcome_label_list, time_stamp_list,
|
@@ -1716,7 +1718,9 @@ class DataSet(_MongoSerializable):
|
|
1716
1718
|
|
1717
1719
|
def _add_raw_arrays(self, circuit, oli_array, time_array, rep_array,
|
1718
1720
|
overwrite_existing, record_zero_counts, aux):
|
1719
|
-
|
1721
|
+
assert not self.bStatic, "Attempting to add arrays to a static DataSet. " + \
|
1722
|
+
"Consider using .copy_nonstatic() to get a mutable DataSet first."
|
1723
|
+
|
1720
1724
|
if rep_array is None:
|
1721
1725
|
if self.repData is not None:
|
1722
1726
|
rep_array = _np.ones(len(oli_array), self.repType)
|
@@ -2114,7 +2118,8 @@ class DataSet(_MongoSerializable):
|
|
2114
2118
|
-------
|
2115
2119
|
None
|
2116
2120
|
"""
|
2117
|
-
if self.bStatic: raise ValueError("Cannot add data to a static DataSet object"
|
2121
|
+
if self.bStatic: raise ValueError("Cannot add data to a static DataSet object." + \
|
2122
|
+
"Consider using .copy_nonstatic() to get a mutable DataSet first.")
|
2118
2123
|
for circuit, dsRow in other_data_set.items():
|
2119
2124
|
self.add_raw_series_data(circuit, dsRow.outcomes, dsRow.time, dsRow.reps, False)
|
2120
2125
|
|
pygsti/data/hypothesistest.py
CHANGED
@@ -253,13 +253,6 @@ class HypothesisTest(object):
|
|
253
253
|
self.passing_graph[hind, :] = _np.ones(len(self.hypotheses), float) / (len(self.hypotheses) - 1)
|
254
254
|
self.passing_graph[hind, hind] = 0.
|
255
255
|
|
256
|
-
# def _check_permissible(self):
|
257
|
-
# """
|
258
|
-
# Todo
|
259
|
-
# """
|
260
|
-
# # Todo : test that the graph is acceptable.
|
261
|
-
# return True
|
262
|
-
|
263
256
|
def add_pvalues(self, pvalues):
|
264
257
|
"""
|
265
258
|
Insert the p-values for the hypotheses.
|
pygsti/drivers/bootstrap.py
CHANGED
@@ -492,52 +492,3 @@ def _to_rms_model(gs_list, target_gs):
|
|
492
492
|
output_gs = target_gs.copy()
|
493
493
|
output_gs.from_vector(_np.mean(gsVecArray))
|
494
494
|
return output_gs
|
495
|
-
|
496
|
-
#Unused?
|
497
|
-
#def gateset_jtracedist(mdl,target_model,mx_basis="gm"):
|
498
|
-
# output = _np.zeros(3,dtype=float)
|
499
|
-
# for i, gate in enumerate(target_model.operations.keys()):
|
500
|
-
# output[i] = _tools.jtracedist(mdl.operations[gate],target_model.operations[gate],mx_basis=mx_basis)
|
501
|
-
## print output
|
502
|
-
# return output
|
503
|
-
#
|
504
|
-
#def gateset_entanglement_fidelity(mdl,target_model):
|
505
|
-
# output = _np.zeros(3,dtype=float)
|
506
|
-
# for i, gate in enumerate(target_model.operations.keys()):
|
507
|
-
# output[i] = _tools.entanglement_fidelity(mdl.operations[gate],target_model.operations[gate])
|
508
|
-
# return output
|
509
|
-
#
|
510
|
-
#def gateset_decomp_angle(mdl):
|
511
|
-
# output = _np.zeros(3,dtype=float)
|
512
|
-
# for i, gate in enumerate(mdl.operations.keys()):
|
513
|
-
# output[i] = _tools.decompose_gate_matrix(mdl.operations[gate]).get('pi rotations',0)
|
514
|
-
# return output
|
515
|
-
#
|
516
|
-
#def gateset_decomp_decay_diag(mdl):
|
517
|
-
# output = _np.zeros(3,dtype=float)
|
518
|
-
# for i, gate in enumerate(mdl.operations.keys()):
|
519
|
-
# output[i] = _tools.decompose_gate_matrix(mdl.operations[gate]).get('decay of diagonal rotation terms',0)
|
520
|
-
# return output
|
521
|
-
#
|
522
|
-
#def gateset_decomp_decay_offdiag(mdl):
|
523
|
-
# output = _np.zeros(3,dtype=float)
|
524
|
-
# for i, gate in enumerate(mdl.operations.keys()):
|
525
|
-
# output[i] = _tools.decompose_gate_matrix(mdl.operations[gate]).get('decay of off diagonal rotation terms',0)
|
526
|
-
# return output
|
527
|
-
#
|
528
|
-
##def gateset_fidelity(mdl,target_model,mx_basis="gm"):
|
529
|
-
## output = _np.zeros(3,dtype=float)
|
530
|
-
## for i, gate in enumerate(target_model.operations.keys()):
|
531
|
-
## output[i] = _tools.fidelity(mdl.operations[gate],target_model.operations[gate])
|
532
|
-
## return output
|
533
|
-
#
|
534
|
-
#def gateset_diamonddist(mdl,target_model,mx_basis="gm"):
|
535
|
-
# output = _np.zeros(3,dtype=float)
|
536
|
-
# for i, gate in enumerate(target_model.operations.keys()):
|
537
|
-
# output[i] = _tools.diamonddist(mdl.operations[gate],target_model.operations[gate],mx_basis=mx_basis)
|
538
|
-
# return output
|
539
|
-
#
|
540
|
-
#def spamrameter(mdl):
|
541
|
-
# firstRho = list(mdl.preps.keys())[0]
|
542
|
-
# firstE = list(mdl.effects.keys())[0]
|
543
|
-
# return _np.dot(mdl.preps[firstRho].T,mdl.effects[firstE])[0,0]
|