pyGSTi 0.9.12.1__cp38-cp38-win_amd64.whl → 0.9.13__cp38-cp38-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 +185 -0
- {pyGSTi-0.9.12.1.dist-info → pyGSTi-0.9.13.dist-info}/RECORD +207 -217
- {pyGSTi-0.9.12.1.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 +42 -28
- 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.cp38-win_amd64.pyd +0 -0
- pygsti/baseobjs/opcalc/fastopcalc.pyx +2 -2
- pygsti/baseobjs/polynomial.py +13 -595
- pygsti/baseobjs/statespace.py +1 -0
- pygsti/circuits/__init__.py +1 -1
- pygsti/circuits/circuit.py +682 -505
- pygsti/circuits/circuitconstruction.py +0 -4
- pygsti/circuits/circuitlist.py +47 -5
- pygsti/circuits/circuitparser/__init__.py +8 -8
- pygsti/circuits/circuitparser/fastcircuitparser.cp38-win_amd64.pyd +0 -0
- pygsti/circuits/circuitstructure.py +3 -3
- pygsti/circuits/cloudcircuitconstruction.py +1 -1
- pygsti/data/datacomparator.py +2 -7
- pygsti/data/dataset.py +46 -44
- pygsti/data/hypothesistest.py +0 -7
- pygsti/drivers/bootstrap.py +0 -49
- pygsti/drivers/longsequence.py +2 -1
- pygsti/evotypes/basereps_cython.cp38-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.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/densitymx/effectreps.pyx +1 -1
- pygsti/evotypes/densitymx/opreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/densitymx/opreps.pyx +2 -2
- pygsti/evotypes/densitymx/statereps.cp38-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.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/effectreps.pyx +0 -4
- pygsti/evotypes/stabilizer/opreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/opreps.pyx +0 -4
- pygsti/evotypes/stabilizer/statereps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/statereps.pyx +1 -5
- pygsti/evotypes/stabilizer/termreps.cp38-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.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/effectreps.pyx +1 -1
- pygsti/evotypes/statevec/opreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/opreps.pyx +2 -2
- pygsti/evotypes/statevec/statereps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/statereps.pyx +1 -1
- pygsti/evotypes/statevec/termreps.cp38-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/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 +14 -55
- pygsti/forwardsims/mapforwardsim.py +69 -18
- pygsti/forwardsims/mapforwardsim_calc_densitymx.cp38-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 +63 -15
- pygsti/forwardsims/termforwardsim.py +8 -110
- pygsti/forwardsims/termforwardsim_calc_stabilizer.cp38-win_amd64.pyd +0 -0
- pygsti/forwardsims/termforwardsim_calc_statevec.cp38-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 +2 -4
- pygsti/modelmembers/operations/affineshiftop.py +1 -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 +2 -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 +0 -79
- 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 +6 -4
- 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 +800 -65
- 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 +73 -138
- 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 +142 -68
- pygsti/protocols/modeltest.py +6 -10
- 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 +8 -2
- 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 +326 -504
- pygsti/tools/basistools.py +9 -36
- pygsti/tools/edesigntools.py +124 -96
- pygsti/tools/fastcalc.cp38-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.1.dist-info/METADATA +0 -155
- 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.1.dist-info → pyGSTi-0.9.13.dist-info}/LICENSE +0 -0
- {pyGSTi-0.9.12.1.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,
|
@@ -2164,7 +2164,7 @@ def _get_kcoverage_template_k2(n):
|
|
2164
2164
|
def invert(bstr):
|
2165
2165
|
return [(0 if x else 1) for x in bstr]
|
2166
2166
|
|
2167
|
-
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))))]
|
2168
2168
|
other_half = [invert(bstr) for bstr in half]
|
2169
2169
|
return half + other_half
|
2170
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)
|
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,
|
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]
|
pygsti/drivers/longsequence.py
CHANGED
@@ -178,6 +178,7 @@ def run_model_test(model_filename_or_object,
|
|
178
178
|
if isinstance(pspec_or_model, _Model):
|
179
179
|
target_model= pspec_or_model
|
180
180
|
elif isinstance(pspec_or_model, _ProcessorSpec):
|
181
|
+
|
181
182
|
target_model= create_explicit_model(pspec_or_model,
|
182
183
|
basis= _load_model(model_filename_or_object).basis)
|
183
184
|
|
@@ -930,7 +931,7 @@ def _get_optimizer(advanced_options, model_being_optimized):
|
|
930
931
|
from pygsti.forwardsims.matrixforwardsim import MatrixForwardSimulator as _MatrixFSim
|
931
932
|
advanced_options = advanced_options or {}
|
932
933
|
default_fditer = 1 if isinstance(model_being_optimized.sim, _MatrixFSim) else 0
|
933
|
-
optimizer = {'maxiter': advanced_options.get('max_iterations',
|
934
|
+
optimizer = {'maxiter': advanced_options.get('max_iterations', 100),
|
934
935
|
'tol': advanced_options.get('tolerance', 1e-6),
|
935
936
|
'fditer': advanced_options.get('finitediff_iterations', default_fditer)}
|
936
937
|
optimizer.update(advanced_options.get('extra_lm_opts', {}))
|
Binary file
|
pygsti/evotypes/chp/opreps.py
CHANGED
@@ -49,11 +49,6 @@ class OpRep(_basereps.OpRep):
|
|
49
49
|
def _chp_ops(self, seed_or_state=None):
|
50
50
|
return self.base_chp_ops
|
51
51
|
|
52
|
-
#def chp_str(self, seed_or_state=None):
|
53
|
-
# op_str = '\n'.join(self.chp_ops(seed_or_state=seed_or_state))
|
54
|
-
# if len(op_str) > 0: op_str += '\n'
|
55
|
-
# return op_str
|
56
|
-
|
57
52
|
def to_dense(self, on_space):
|
58
53
|
try:
|
59
54
|
str_ops = str(self._chp_ops())
|
@@ -217,63 +212,7 @@ class OpRepStochastic(OpRepRandomUnitary):
|
|
217
212
|
|
218
213
|
super(OpRepStochastic, self).__init__(basis, _np.array(rates, 'd'), reps, seed_or_state, state_space)
|
219
214
|
|
220
|
-
#OLD
|
221
|
-
#self.basis = basis
|
222
|
-
#assert (basis.name == 'pp'), "Only Pauli basis is allowed for 'chp' evotype"
|
223
|
-
#
|
224
|
-
#if isinstance(seed_or_state, _RandomState):
|
225
|
-
# self.rand_state = seed_or_state
|
226
|
-
#else:
|
227
|
-
# self.rand_state = _RandomState(seed_or_state)
|
228
|
-
#
|
229
|
-
##TODO: need to fix this: `basis` above functions as basis to make superoperators out of, but here we have
|
230
|
-
## a CHP stochastic op which is given a basis for the space - e.g. a dim=2 vector space for 1 qubit, so
|
231
|
-
## we need to distinguish/specify the basis better for this... and what about rate_poly_dicts (see svterm)
|
232
|
-
#nqubits = state_space.num_qubits
|
233
|
-
#assert(self.basis.dim == 4**nqubits), "Must have an integral number of qubits"
|
234
|
-
#
|
235
|
-
#std_chp_ops = _itgs.standard_gatenames_chp_conversions()
|
236
|
-
#
|
237
|
-
## For CHP, need to make a Composed + EmbeddedOp for the super operators
|
238
|
-
## For lower overhead, make this directly using the rep instead of with objects
|
239
|
-
#self.stochastic_superop_reps = []
|
240
|
-
#for label in self.basis.labels[1:]:
|
241
|
-
# combined_chp_ops = []
|
242
|
-
#
|
243
|
-
# for i, pauli in enumerate(label):
|
244
|
-
# name = 'Gi' if pauli == "I" else 'G%spi' % pauli.lower()
|
245
|
-
# chp_op = std_chp_ops[name]
|
246
|
-
# chp_op_targeted = [op.replace('0', str(i)) for op in chp_op]
|
247
|
-
# combined_chp_ops.extend(chp_op_targeted)
|
248
|
-
#
|
249
|
-
# sub_rep = OpRep(combined_chp_ops, state_space)
|
250
|
-
# self.stochastic_superop_reps.append(sub_rep)
|
251
|
-
#self.rates = initial_rates
|
252
|
-
#super(OpRepStochastic, self).__init__([], state_space) # don't store any chp_ops in base
|
253
|
-
|
254
215
|
def update_rates(self, rates):
|
255
216
|
unitary_rates = [1 - sum(rates)] + list(rates)
|
256
217
|
self.rates[:] = rates
|
257
218
|
self.update_unitary_rates(unitary_rates)
|
258
|
-
|
259
|
-
#TODO REMOVE - covered by OpRepRandomUnitary
|
260
|
-
#def chp_ops(self, seed_or_state=None):
|
261
|
-
# # Optionally override RNG for this call
|
262
|
-
# if seed_or_state is not None:
|
263
|
-
# if isinstance(seed_or_state, _np.random.RandomState):
|
264
|
-
# rand_state = seed_or_state
|
265
|
-
# else:
|
266
|
-
# rand_state = _np.random.RandomState(seed_or_state)
|
267
|
-
# else:
|
268
|
-
# rand_state = self.rand_state
|
269
|
-
#
|
270
|
-
# rates = self.rates
|
271
|
-
# all_rates = [*rates, 1.0 - sum(rates)] # Include identity so that probabilities are 1
|
272
|
-
# index = rand_state.choice(self.basis.size, p=all_rates)
|
273
|
-
#
|
274
|
-
# # If final entry, no operation selected
|
275
|
-
# if index == self.basis.size - 1:
|
276
|
-
# return []
|
277
|
-
#
|
278
|
-
# rep = self.stochastic_superop_reps[index]
|
279
|
-
# return rep._chp_ops()
|
pygsti/evotypes/chp/statereps.py
CHANGED
@@ -40,16 +40,6 @@ class StateRep(_basereps.StateRep):
|
|
40
40
|
def num_qubits(self):
|
41
41
|
return self.state_space.num_qubits
|
42
42
|
|
43
|
-
#REMOVE
|
44
|
-
#def chp_ops(self, seed_or_state=None):
|
45
|
-
# return self.base_chp_ops
|
46
|
-
|
47
|
-
#REMOVE
|
48
|
-
#def chp_str(self, seed_or_state=None):
|
49
|
-
# op_str = '\n'.join(self.chp_ops(seed_or_state=seed_or_state))
|
50
|
-
# if len(op_str) > 0: op_str += '\n'
|
51
|
-
# return op_str
|
52
|
-
|
53
43
|
def copy(self):
|
54
44
|
return StateRep(self.chp_ops, self.state_space)
|
55
45
|
|
@@ -87,25 +77,3 @@ class StateRepComposed(StateRep):
|
|
87
77
|
def actionable_staterep(self):
|
88
78
|
state_rep = self.state_rep.actionable_staterep()
|
89
79
|
return self.op_rep.acton(state_rep)
|
90
|
-
|
91
|
-
#REMOVE
|
92
|
-
# def chp_ops(self, seed_or_state=None):
|
93
|
-
# return self.state_rep.chp_ops(seed_or_state=seed_or_state) \
|
94
|
-
# + self.op_rep.chp_ops(seed_or_state=seed_or_state)
|
95
|
-
|
96
|
-
# TODO: Untested, only support computational and composed for now
|
97
|
-
#class StateRepTensorProduct(StateRep):
|
98
|
-
# def __init__(self, factor_state_reps, state_space):
|
99
|
-
# self.factor_reps = factor_state_reps
|
100
|
-
# super(StateRepTensorProduct, self).__init__([], state_space)
|
101
|
-
# self.reps_have_changed()
|
102
|
-
#
|
103
|
-
# def reps_have_changed(self):
|
104
|
-
# chp_ops = []
|
105
|
-
# current_iqubit = 0
|
106
|
-
# for factor in self.factor_reps:
|
107
|
-
# local_to_tp_index = {str(iloc): str(itp) for iloc, itp in
|
108
|
-
# enumerate(range(current_iqubit, current_iqubit + factor.num_qubits))}
|
109
|
-
# chp_ops.extend([_update_chp_op(op, local_to_tp_index) for op in self.chp_ops])
|
110
|
-
# current_iqubit += factor.num_qubits
|
111
|
-
# self.chp_ops = chp_ops
|
@@ -147,7 +147,7 @@ namespace CReps_densitymx {
|
|
147
147
|
finalIndx += ((finds >> k) & 1) * 3 * base;
|
148
148
|
base = base >> 2; // /= 4 so base == 4**(N-1-k)
|
149
149
|
}
|
150
|
-
|
150
|
+
|
151
151
|
//Apply result
|
152
152
|
if(parity(finds & _zvals_int))
|
153
153
|
ret -= _abs_elval * state->_dataptr[finalIndx]; // minus sign
|
@@ -157,15 +157,14 @@ namespace CReps_densitymx {
|
|
157
157
|
return ret;
|
158
158
|
}
|
159
159
|
|
160
|
-
INT EffectCRep_Computational::parity(INT x) {
|
161
|
-
|
162
|
-
x
|
163
|
-
x
|
164
|
-
x
|
165
|
-
x
|
166
|
-
x
|
167
|
-
|
168
|
-
return x & 1; // return the last bit (0 or 1)
|
160
|
+
inline INT EffectCRep_Computational::parity(INT x) {
|
161
|
+
x ^= (x >> 32);
|
162
|
+
x ^= (x >> 16);
|
163
|
+
x ^= (x >> 8);
|
164
|
+
x ^= (x >> 4);
|
165
|
+
x ^= (x >> 2);
|
166
|
+
x ^= (x >> 1);
|
167
|
+
return x & 1; // Return the last bit
|
169
168
|
}
|
170
169
|
|
171
170
|
|
Binary file
|
@@ -108,7 +108,7 @@ cdef class EffectRepTensorProduct(EffectRep):
|
|
108
108
|
cdef _np.ndarray[_np.int64_t, ndim=1, mode='c'] factor_dims = \
|
109
109
|
_np.ascontiguousarray(_np.array([fct.state_space.dim for fct in povm_factors], _np.int64))
|
110
110
|
|
111
|
-
cdef INT dim = _np.
|
111
|
+
cdef INT dim = _np.prod(factor_dims)
|
112
112
|
cdef INT nfactors = len(povm_factors)
|
113
113
|
self.povm_factors = povm_factors
|
114
114
|
self.effect_labels = effect_labels
|
Binary file
|
@@ -540,7 +540,7 @@ def _compute_embedding_quantities_cachekey(state_space, target_labels, embedded_
|
|
540
540
|
# final map just acts as identity w.r.t.
|
541
541
|
labelIndices = [tensorProdBlkLabels.index(label) for label in target_labels]
|
542
542
|
cdef _np.ndarray[_np.int64_t, ndim=1, mode='c'] action_inds = _np.array(labelIndices, _np.int64)
|
543
|
-
assert(_np.
|
543
|
+
assert(_np.prod([num_basis_els[i] for i in action_inds]) == embedded_rep_dim), \
|
544
544
|
"Embedded operation has dimension (%d) inconsistent with the given target labels (%s)" % (
|
545
545
|
embedded_rep_dim, str(target_labels))
|
546
546
|
|
@@ -550,7 +550,7 @@ def _compute_embedding_quantities_cachekey(state_space, target_labels, embedded_
|
|
550
550
|
cdef INT ncomponents_in_active_block = len(state_space.tensor_product_block_labels(active_block_index))
|
551
551
|
cdef INT embedded_dim = embedded_rep_dim
|
552
552
|
cdef _np.ndarray[_np.int64_t, ndim=1, mode='c'] blocksizes = \
|
553
|
-
_np.array([_np.
|
553
|
+
_np.array([_np.prod(state_space.tensor_product_block_dimensions(k))
|
554
554
|
for k in range(nblocks)], _np.int64)
|
555
555
|
cdef INT i, j
|
556
556
|
|