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
Binary file
|
@@ -163,7 +163,7 @@ cdef class StateRepTensorProduct(StateRep):
|
|
163
163
|
|
164
164
|
def __cinit__(self, factor_state_reps, state_space):
|
165
165
|
self.factor_reps = factor_state_reps
|
166
|
-
dim = _np.
|
166
|
+
dim = _np.prod([fct.dim for fct in self.factor_reps])
|
167
167
|
self._cinit_base(_np.zeros(dim, 'd'), state_space)
|
168
168
|
self.reps_have_changed()
|
169
169
|
|
@@ -13,12 +13,13 @@ POVM effect representation classes for the `densitymx_slow` evolution type.
|
|
13
13
|
import numpy as _np
|
14
14
|
|
15
15
|
# import functools as _functools
|
16
|
-
from .. import basereps as _basereps
|
17
16
|
from pygsti.baseobjs.statespace import StateSpace as _StateSpace
|
18
17
|
from ...tools import matrixtools as _mt
|
19
18
|
|
20
19
|
|
21
|
-
class EffectRep
|
20
|
+
class EffectRep:
|
21
|
+
"""Any representation of an "effect" in the sense of a POVM."""
|
22
|
+
|
22
23
|
def __init__(self, state_space):
|
23
24
|
self.state_space = _StateSpace.cast(state_space)
|
24
25
|
|
@@ -27,6 +28,10 @@ class EffectRep(_basereps.EffectRep):
|
|
27
28
|
|
28
29
|
|
29
30
|
class EffectRepConjugatedState(EffectRep):
|
31
|
+
"""
|
32
|
+
A real superket representation of an "effect" in the sense of a POVM.
|
33
|
+
Internally uses a StateRepDense object to hold the real superket.
|
34
|
+
"""
|
30
35
|
|
31
36
|
def __init__(self, state_rep):
|
32
37
|
self.state_rep = state_rep
|
@@ -100,11 +105,6 @@ class EffectRepTensorProduct(EffectRep):
|
|
100
105
|
super(EffectRepTensorProduct, self).__init__(state_space)
|
101
106
|
self.factor_effects_have_changed()
|
102
107
|
|
103
|
-
#TODO: fix this:
|
104
|
-
#def __reduce__(self):
|
105
|
-
# return (EffectRepTensorProduct,
|
106
|
-
# (self.kron_array, self.factor_dims, self.nfactors, self.max_factor_dim, self.dim))
|
107
|
-
|
108
108
|
def to_dense(self, on_space, outvec=None):
|
109
109
|
|
110
110
|
if on_space not in ('minimal', 'HilbertSchmidt'):
|
@@ -159,22 +159,6 @@ class EffectRepTensorProduct(EffectRep):
|
|
159
159
|
def factor_effects_have_changed(self):
|
160
160
|
self._fill_fast_kron() # updates effect reps
|
161
161
|
|
162
|
-
#def to_dense(self):
|
163
|
-
# if len(self.factors) == 0: return _np.empty(0, complex if self._evotype == "statevec" else 'd')
|
164
|
-
# #NOTE: moved a fast version of to_dense to replib - could use that if need a fast to_dense call...
|
165
|
-
#
|
166
|
-
# factorPOVMs = self.factors
|
167
|
-
# ret = factorPOVMs[0][self.effectLbls[0]].to_dense()
|
168
|
-
# for i in range(1, len(factorPOVMs)):
|
169
|
-
# ret = _np.kron(ret, factorPOVMs[i][self.effectLbls[i]].to_dense())
|
170
|
-
# return ret
|
171
|
-
# elif self._evotype == "stabilizer":
|
172
|
-
# # each factor is a StabilizerEffectVec
|
173
|
-
# raise ValueError("Cannot convert Stabilizer tensor product effect to an array!")
|
174
|
-
# # should be using effect.outcomes property...
|
175
|
-
# else: # self._evotype in ("svterm","cterm")
|
176
|
-
# raise NotImplementedError("to_dense() not implemented for %s evolution type" % self._evotype)
|
177
|
-
|
178
162
|
|
179
163
|
class EffectRepComposed(EffectRep):
|
180
164
|
def __init__(self, op_rep, effect_rep, op_id, state_space):
|
@@ -17,7 +17,6 @@ import scipy.sparse as _sps
|
|
17
17
|
from scipy.sparse.linalg import LinearOperator
|
18
18
|
|
19
19
|
from .statereps import StateRepDense as _StateRepDense
|
20
|
-
from .. import basereps as _basereps
|
21
20
|
from pygsti.baseobjs.statespace import StateSpace as _StateSpace
|
22
21
|
from ...tools import basistools as _bt
|
23
22
|
from ...tools import internalgates as _itgs
|
@@ -26,7 +25,11 @@ from ...tools import matrixtools as _mt
|
|
26
25
|
from ...tools import optools as _ot
|
27
26
|
|
28
27
|
|
29
|
-
class OpRep
|
28
|
+
class OpRep:
|
29
|
+
"""
|
30
|
+
A real superoperator on Hilbert-Schmidt space.
|
31
|
+
"""
|
32
|
+
|
30
33
|
def __init__(self, state_space):
|
31
34
|
self.state_space = state_space
|
32
35
|
|
@@ -41,6 +44,10 @@ class OpRep(_basereps.OpRep):
|
|
41
44
|
raise NotImplementedError()
|
42
45
|
|
43
46
|
def aslinearoperator(self):
|
47
|
+
"""
|
48
|
+
Return a SciPy LinearOperator that accepts superket representations of vectors
|
49
|
+
in Hilbert-Schmidt space and returns a vector of that same representation.
|
50
|
+
"""
|
44
51
|
def mv(v):
|
45
52
|
if v.ndim == 2 and v.shape[1] == 1: v = v[:, 0]
|
46
53
|
in_state = _StateRepDense(_np.ascontiguousarray(v, 'd'), self.state_space, None)
|
@@ -54,6 +61,12 @@ class OpRep(_basereps.OpRep):
|
|
54
61
|
|
55
62
|
|
56
63
|
class OpRepDenseSuperop(OpRep):
|
64
|
+
"""
|
65
|
+
A real superoperator on Hilbert-Schmidt space.
|
66
|
+
The operator's action (and adjoint action) work with Hermitian matrices
|
67
|
+
stored as *vectors* in their real superket representations.
|
68
|
+
"""
|
69
|
+
|
57
70
|
def __init__(self, mx, basis, state_space):
|
58
71
|
state_space = _StateSpace.cast(state_space)
|
59
72
|
if mx is None:
|
@@ -174,7 +187,7 @@ class OpRepStandard(OpRepDenseSuperop):
|
|
174
187
|
state_space = _StateSpace.cast(state_space)
|
175
188
|
assert(superop.shape[0] == state_space.dim)
|
176
189
|
|
177
|
-
super(OpRepStandard, self).__init__(superop, state_space)
|
190
|
+
super(OpRepStandard, self).__init__(superop, basis, state_space)
|
178
191
|
|
179
192
|
|
180
193
|
class OpRepKraus(OpRep):
|
@@ -257,10 +270,6 @@ class OpRepStochastic(OpRepRandomUnitary):
|
|
257
270
|
self.rates[:] = rates
|
258
271
|
self.update_unitary_rates(unitary_rates)
|
259
272
|
|
260
|
-
#class OpRepClifford(OpRep): # TODO?
|
261
|
-
# #def __init__(self, unitarymx, symplecticrep):
|
262
|
-
# # pass
|
263
|
-
|
264
273
|
|
265
274
|
class OpRepComposed(OpRep):
|
266
275
|
|
@@ -362,13 +371,6 @@ class OpRepEmbedded(OpRep):
|
|
362
371
|
self.offset = sum(blocksizes[0:self.active_block_index])
|
363
372
|
super(OpRepEmbedded, self).__init__(state_space)
|
364
373
|
|
365
|
-
#def __reduce__(self):
|
366
|
-
# return (DMOpRepEmbedded, (self.embedded,
|
367
|
-
# self.num_basis_els, self.action_inds,
|
368
|
-
# self.blocksizes, self.embeddedDim,
|
369
|
-
# self.ncomponents, self.active_block_index,
|
370
|
-
# self.nblocks, self.dim))
|
371
|
-
|
372
374
|
def _acton_other_blocks_trivially(self, output_state, state):
|
373
375
|
offset = 0
|
374
376
|
for iBlk, blockSize in enumerate(self.blocksizes):
|
@@ -453,15 +455,6 @@ class OpRepExpErrorgen(OpRep):
|
|
453
455
|
def exp_params(self):
|
454
456
|
return (self.mu, self.eta, self.m_star, self.s)
|
455
457
|
|
456
|
-
#def __reduce__(self):
|
457
|
-
# if self.unitary_postfactor is None:
|
458
|
-
# return (DMOpRepLindblad, (self.errorgen_rep, self.mu, self.eta, self.m_star, self.s,
|
459
|
-
# _np.empty(0, 'd'), _np.empty(0, _np.int64), _np.zeros(1, _np.int64)))
|
460
|
-
# else:
|
461
|
-
# return (DMOpRepLindblad, (self.errorgen_rep, self.mu, self.eta, self.m_star, self.s,
|
462
|
-
# self.unitary_postfactor.data, self.unitary_postfactor.indices,
|
463
|
-
# self.unitary_postfactor.indptr))
|
464
|
-
|
465
458
|
def acton(self, state):
|
466
459
|
""" Act this gate map on an input state """
|
467
460
|
statedata = state.data.copy() # must COPY because _custom... call below *modifies* "b" arg
|
@@ -14,7 +14,6 @@ import functools as _functools
|
|
14
14
|
|
15
15
|
import numpy as _np
|
16
16
|
|
17
|
-
from .. import basereps as _basereps
|
18
17
|
from pygsti.baseobjs.statespace import StateSpace as _StateSpace
|
19
18
|
from ...tools import basistools as _bt
|
20
19
|
from ...tools import optools as _ot
|
@@ -25,13 +24,17 @@ except ImportError:
|
|
25
24
|
_fastcalc = None
|
26
25
|
|
27
26
|
|
28
|
-
class StateRep
|
27
|
+
class StateRep:
|
28
|
+
"""A real superket representation of an element in Hilbert-Schmidt space."""
|
29
|
+
|
29
30
|
def __init__(self, data, state_space):
|
30
31
|
#vec = _np.asarray(vec, dtype='d')
|
31
32
|
assert(data.dtype == _np.dtype('d'))
|
32
33
|
self.data = _np.require(data.copy(), requirements=['OWNDATA', 'C_CONTIGUOUS'])
|
33
34
|
self.state_space = _StateSpace.cast(state_space)
|
34
|
-
|
35
|
+
ds0 = self.data.shape[0]
|
36
|
+
assert(ds0 == self.state_space.dim)
|
37
|
+
assert(ds0 == self.data.size)
|
35
38
|
|
36
39
|
def __reduce__(self):
|
37
40
|
return (StateRep, (self.data, self.state_space), (self.data.flags.writeable,))
|
@@ -62,6 +65,10 @@ class StateRep(_basereps.StateRep):
|
|
62
65
|
|
63
66
|
|
64
67
|
class StateRepDense(StateRep):
|
68
|
+
"""
|
69
|
+
An almost-trivial wrapper around StateRep.
|
70
|
+
Implements the "base" property and defines a trivial "base_has_changed" function.
|
71
|
+
"""
|
65
72
|
|
66
73
|
def __init__(self, data, state_space, basis):
|
67
74
|
#ignore basis for now (self.basis = basis in future?)
|
pygsti/evotypes/evotype.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import importlib as _importlib
|
2
2
|
|
3
3
|
from . import basereps as _basereps
|
4
|
+
from pygsti.baseobjs.statespace import StateSpace as _StateSpace
|
4
5
|
|
5
6
|
|
6
7
|
class Evotype(object):
|
@@ -50,10 +51,46 @@ class Evotype(object):
|
|
50
51
|
}
|
51
52
|
|
52
53
|
@classmethod
|
53
|
-
def cast(cls, obj, default_prefer_dense_reps=
|
54
|
+
def cast(cls, obj, default_prefer_dense_reps=None, state_space=None):
|
55
|
+
"""
|
56
|
+
Cast the specified object to an Evotype with options for default Evotype
|
57
|
+
handling.
|
58
|
+
|
59
|
+
Parameters
|
60
|
+
----------
|
61
|
+
obj : Evotype or str
|
62
|
+
Object to cast to an Evotype. If already an Evotype the object is simply
|
63
|
+
returned. Otherwise if a string we attempt to cast it to a recognized
|
64
|
+
evotype option. If the string "default" is passed in then we determine
|
65
|
+
the type of evotype used in conjunction with the two optional kwargs below.
|
66
|
+
|
67
|
+
default_prefer_dense_reps : None or bool, optional (default None)
|
68
|
+
Flag to indicate preference for dense representation types when casting
|
69
|
+
a string. If None then there is no preference and this will be determined
|
70
|
+
by the optional state_space kwarg, if present. Otherwise if a boolean value
|
71
|
+
this selection overrides any logic based on the state space.
|
72
|
+
|
73
|
+
state_space : StateSpace, optional (default None)
|
74
|
+
If not None then the dimension of the state space is used to determine whether
|
75
|
+
or not to prefer the use of dense representation types when not already specified
|
76
|
+
by the default_prefer_dense_reps kwarg.
|
77
|
+
|
78
|
+
Returns
|
79
|
+
-------
|
80
|
+
Evotype
|
81
|
+
"""
|
54
82
|
if isinstance(obj, Evotype):
|
55
83
|
return obj
|
56
|
-
|
84
|
+
|
85
|
+
if default_prefer_dense_reps is None:
|
86
|
+
if state_space is None:
|
87
|
+
default_prefer_dense_reps = False #reproduces legacy behavior.
|
88
|
+
else:
|
89
|
+
if not isinstance(state_space, _StateSpace):
|
90
|
+
raise ValueError('state_space must be a StateSpace object.')
|
91
|
+
default_prefer_dense_reps = False if state_space.dim > 64 else True #HARDCODED
|
92
|
+
|
93
|
+
if obj == "default":
|
57
94
|
return Evotype(cls.default_evotype, default_prefer_dense_reps)
|
58
95
|
else: # assume obj is a string naming an evotype
|
59
96
|
return Evotype(str(obj), default_prefer_dense_reps)
|
Binary file
|
@@ -39,10 +39,6 @@ cdef class EffectRep(_basereps_cython.EffectRep):
|
|
39
39
|
def nqubits(self):
|
40
40
|
return self.state_space.num_qubits
|
41
41
|
|
42
|
-
#@property
|
43
|
-
#def dim(self):
|
44
|
-
# return 2**(self.c_effect._n) # assume "unitary evolution"-type mode
|
45
|
-
|
46
42
|
def probability(self, StateRep state not None):
|
47
43
|
#unnecessary (just put in signature): cdef StateRep st = <StateRep?>state
|
48
44
|
return self.c_effect.probability(state.c_state)
|
Binary file
|
@@ -40,10 +40,6 @@ cdef class OpRep(_basereps_cython.OpRep):
|
|
40
40
|
def nqubits(self):
|
41
41
|
return self.state_space.num_qubits
|
42
42
|
|
43
|
-
#@property
|
44
|
-
#def dim(self):
|
45
|
-
# return 2**(self.nqubits) # assume "unitary evolution"-type mode
|
46
|
-
|
47
43
|
def acton(self, StateRep state not None):
|
48
44
|
cdef INT n = self.c_rep._n
|
49
45
|
cdef INT namps = state.c_state._namps
|
Binary file
|
@@ -49,10 +49,6 @@ cdef class StateRep(_basereps_cython.StateRep):
|
|
49
49
|
def nqubits(self):
|
50
50
|
return self.state_space.num_qubits
|
51
51
|
|
52
|
-
#@property
|
53
|
-
#def dim(self):
|
54
|
-
# return 2**(self.c_state._n) # assume "unitary evolution"-type mode
|
55
|
-
|
56
52
|
def actionable_staterep(self):
|
57
53
|
# return a state rep that can be acted on by op reps or mapped to
|
58
54
|
# a probability/amplitude by POVM effect reps.
|
@@ -129,7 +125,7 @@ cdef class StateRepTensorProduct(StateRep):
|
|
129
125
|
def __cinit__(self, factor_state_reps, state_space):
|
130
126
|
self.factor_reps = factor_state_reps
|
131
127
|
n = sum([sf.nqubits for sf in self.factor_reps]) # total number of qubits
|
132
|
-
np = int(_np.
|
128
|
+
np = int(_np.prod([len(sf.pvectors) for sf in self.factor_reps]))
|
133
129
|
self._cinit_base(_np.zeros((2 * n, 2 * n), _np.int64),
|
134
130
|
_np.zeros((np, 2 * n), _np.int64),
|
135
131
|
_np.ones(np, complex),
|
Binary file
|
@@ -107,10 +107,3 @@ cdef class TermRep(_basereps_cython.TermRep):
|
|
107
107
|
return TermRep(self.coeff.copy(), self.magnitude, self.logmagnitude,
|
108
108
|
self.pre_state, self.post_state, self.pre_effect, self.post_effect,
|
109
109
|
self.pre_ops, self.post_ops)
|
110
|
-
|
111
|
-
#Not needed - and this implementation is quite right as it will need to change
|
112
|
-
# the ordering of the pre/post ops also.
|
113
|
-
#def conjugate(self):
|
114
|
-
# return TermRep(self.coeff.copy(), self.magnitude, self.logmagnitude,
|
115
|
-
# self.post_state, self.pre_state, self.post_effect, self.pre_effect,
|
116
|
-
# self.post_ops, self.pre_ops)
|
@@ -23,10 +23,6 @@ class EffectRep(_basereps.EffectRep):
|
|
23
23
|
def nqubits(self):
|
24
24
|
return self.state_space.num_qubits
|
25
25
|
|
26
|
-
#@property
|
27
|
-
#def dim(self):
|
28
|
-
# return 2**self.nqubits # assume "unitary evolution"-type mode
|
29
|
-
|
30
26
|
def probability(self, state):
|
31
27
|
return state.sframe.measurement_probability(self.zvals, check=True) # use check for now?
|
32
28
|
|
@@ -37,10 +33,6 @@ class EffectRep(_basereps.EffectRep):
|
|
37
33
|
return _mt.zvals_to_dense(self.zvals, superket=bool(on_space not in ('minimal', 'Hilbert')))
|
38
34
|
|
39
35
|
|
40
|
-
#class EffectRepConjugatedState(EffectRep):
|
41
|
-
# pass # TODO - this should be possible
|
42
|
-
|
43
|
-
|
44
36
|
class EffectRepComputational(EffectRep):
|
45
37
|
|
46
38
|
def __init__(self, zvals, basis, state_space):
|
@@ -49,17 +41,6 @@ class EffectRepComputational(EffectRep):
|
|
49
41
|
assert(self.state_space.num_qubits == len(self.zvals))
|
50
42
|
super(EffectRepComputational, self).__init__(state_space)
|
51
43
|
|
52
|
-
#@property
|
53
|
-
#def outcomes(self):
|
54
|
-
# """
|
55
|
-
# The 0/1 outcomes identifying this effect within its StabilizerZPOVM
|
56
|
-
#
|
57
|
-
# Returns
|
58
|
-
# -------
|
59
|
-
# numpy.ndarray
|
60
|
-
# """
|
61
|
-
# return self.zvals
|
62
|
-
|
63
44
|
def __str__(self):
|
64
45
|
nQubits = len(self.zvals)
|
65
46
|
s = "Stabilizer effect vector for %d qubits with outcome %s" % (nQubits, str(self.zvals))
|
@@ -80,9 +61,6 @@ class EffectRepComposed(EffectRep):
|
|
80
61
|
|
81
62
|
super(EffectRepComposed, self).__init__(state_space)
|
82
63
|
|
83
|
-
#def __reduce__(self):
|
84
|
-
# return (EffectRepComposed, (self.op_rep, self.effect_rep, self.op_id, self.state_space))
|
85
|
-
|
86
64
|
def probability(self, state):
|
87
65
|
state = self.op_rep.acton(state) # *not* acton_adjoint
|
88
66
|
return self.effect_rep.probability(state)
|
@@ -34,10 +34,6 @@ class OpRep(_basereps.OpRep):
|
|
34
34
|
def nqubits(self):
|
35
35
|
return self.state_space.num_qubits
|
36
36
|
|
37
|
-
#@property
|
38
|
-
#def dim(self):
|
39
|
-
# return 2**(self.nqubits) # assume "unitary evolution"-type mode
|
40
|
-
|
41
37
|
|
42
38
|
class OpRepClifford(OpRep):
|
43
39
|
def __init__(self, unitarymx, symplecticrep, basis, state_space):
|
@@ -42,10 +42,6 @@ class StateRep(_basereps.StateRep):
|
|
42
42
|
def nqubits(self):
|
43
43
|
return self.sframe.n
|
44
44
|
|
45
|
-
#@property
|
46
|
-
#def dim(self):
|
47
|
-
# return 2**self.nqubits # assume "unitary evolution"-type mode
|
48
|
-
|
49
45
|
def actionable_staterep(self):
|
50
46
|
# return a state rep that can be acted on by op reps or mapped to
|
51
47
|
# a probability/amplitude by POVM effect reps.
|
Binary file
|
@@ -111,7 +111,7 @@ cdef class EffectRepTensorProduct(EffectRep):
|
|
111
111
|
cdef _np.ndarray[_np.int64_t, ndim=1, mode='c'] factor_dims = \
|
112
112
|
_np.ascontiguousarray(_np.array([fct.state_space.udim for fct in povm_factors], _np.int64))
|
113
113
|
|
114
|
-
cdef INT dim = _np.
|
114
|
+
cdef INT dim = _np.prod(factor_dims)
|
115
115
|
cdef INT nfactors = len(self.povm_factors)
|
116
116
|
self.povm_factors = povm_factors
|
117
117
|
self.effect_labels = effect_labels
|
Binary file
|
@@ -246,7 +246,7 @@ cdef class OpRepEmbedded(OpRep):
|
|
246
246
|
# final map just acts as identity w.r.t.
|
247
247
|
labelIndices = [tensorProdBlkLabels.index(label) for label in target_labels]
|
248
248
|
cdef _np.ndarray[_np.int64_t, ndim=1, mode='c'] action_inds = _np.array(labelIndices, _np.int64)
|
249
|
-
assert(_np.
|
249
|
+
assert(_np.prod([num_basis_els[i] for i in action_inds]) == embedded_rep.dim), \
|
250
250
|
"Embedded operation has dimension (%d) inconsistent with the given target labels (%s)" % (
|
251
251
|
embedded_rep.dim, str(target_labels))
|
252
252
|
|
@@ -256,7 +256,7 @@ cdef class OpRepEmbedded(OpRep):
|
|
256
256
|
cdef INT ncomponents_in_active_block = len(state_space.tensor_product_block_labels(active_block_index))
|
257
257
|
cdef INT embedded_dim = embedded_rep.dim
|
258
258
|
cdef _np.ndarray[_np.int64_t, ndim=1, mode='c'] blocksizes = \
|
259
|
-
_np.array([_np.
|
259
|
+
_np.array([_np.prod(state_space.tensor_product_block_udimensions(k))
|
260
260
|
for k in range(nblocks)], _np.int64)
|
261
261
|
cdef INT i, j
|
262
262
|
|
Binary file
|
@@ -150,7 +150,7 @@ cdef class StateRepTensorProduct(StateRep):
|
|
150
150
|
|
151
151
|
def __init__(self, factor_state_reps, state_space):
|
152
152
|
self.factor_reps = factor_state_reps
|
153
|
-
dim = _np.
|
153
|
+
dim = _np.prod([fct.dim for fct in self.factor_reps])
|
154
154
|
self._cinit_base(_np.zeros(dim, complex), state_space, None) # TODO: compute a tensorprod basis?
|
155
155
|
self.reps_have_changed()
|
156
156
|
|
Binary file
|
@@ -112,13 +112,6 @@ cdef class TermRep(_basereps_cython.TermRep):
|
|
112
112
|
self.pre_state, self.post_state, self.pre_effect, self.post_effect,
|
113
113
|
self.pre_ops, self.post_ops)
|
114
114
|
|
115
|
-
#Not needed - and this implementation is quite right as it will need to change
|
116
|
-
# the ordering of the pre/post ops also.
|
117
|
-
#def conjugate(self):
|
118
|
-
# return TermRep(self.coeff.copy(), self.magnitude, self.logmagnitude,
|
119
|
-
# self.post_state, self.pre_state, self.post_effect, self.pre_effect,
|
120
|
-
# self.post_ops, self.pre_ops)
|
121
|
-
|
122
115
|
|
123
116
|
#Note: to use direct term reps (numerical coeffs) we'll need to update
|
124
117
|
# what the members are called and add methods as was done for TermRep.
|
@@ -180,9 +180,6 @@ class EffectRepComposed(EffectRep):
|
|
180
180
|
|
181
181
|
super(EffectRepComposed, self).__init__(effect_rep.state_space)
|
182
182
|
|
183
|
-
#def __reduce__(self):
|
184
|
-
# return (EffectRepComposed, (self.op_rep, self.effect_rep, self.op_id, self.state_space))
|
185
|
-
|
186
183
|
def probability(self, state):
|
187
184
|
state = self.op_rep.acton(state) # *not* acton_adjoint
|
188
185
|
return self.effect_rep.probability(state)
|
@@ -107,11 +107,6 @@ class OpRepStandard(OpRepDenseUnitary):
|
|
107
107
|
super(OpRepStandard, self).__init__(U, basis, state_space)
|
108
108
|
|
109
109
|
|
110
|
-
#class OpRepStochastic(OpRepDense):
|
111
|
-
# - maybe we could add this, but it wouldn't be a "dense" op here,
|
112
|
-
# perhaps we need to change API?
|
113
|
-
|
114
|
-
|
115
110
|
class OpRepComposed(OpRep):
|
116
111
|
# exactly the same as densitymx case
|
117
112
|
def __init__(self, factor_op_reps, state_space):
|
pygsti/extras/__init__.py
CHANGED
@@ -1235,9 +1235,11 @@ class StabilityAnalyzer(object):
|
|
1235
1235
|
|
1236
1236
|
# If we're not testing a single spectrum we need to flatten the >1D array.
|
1237
1237
|
if len(_np.shape(spectra)) > 1:
|
1238
|
+
# Use flatten (rather than ravel) to ensure a copy is made.
|
1238
1239
|
powerlist = spectra[indices].flatten()
|
1239
1240
|
# If we're testing a single spectrum, we can just copy the 1D array.
|
1240
|
-
else:
|
1241
|
+
else:
|
1242
|
+
powerlist = spectra[indices].copy()
|
1241
1243
|
|
1242
1244
|
# The indices that will go with the elements in the flattened spectra.
|
1243
1245
|
powerindices = [tup for tup in _itertools.product(*iterBenjHoch)]
|
@@ -10,3 +10,15 @@
|
|
10
10
|
|
11
11
|
from .core import PhysicalProcess, InterpolatedDenseOp, InterpolatedOpFactory
|
12
12
|
from .process_tomography import vec, unvec, run_process_tomography
|
13
|
+
|
14
|
+
# Note from Riley on September, 2024:
|
15
|
+
#
|
16
|
+
# vec is deprecated, and shouldn't be called anywhere in the codebase.
|
17
|
+
#
|
18
|
+
# unvec is deprecated and replaced with unvec_square; the latter function
|
19
|
+
# isn't imported here because we don't want people to access it just from
|
20
|
+
# the pygsti.extras.interpygate namespace.
|
21
|
+
#
|
22
|
+
# Ideally we'd remove vec and unvec from the pygsti.extras.interpygate namespace
|
23
|
+
# and only have them available in pygsti.extras.interpygate.process_tomography.
|
24
|
+
#
|
@@ -241,15 +241,6 @@ class InterpolatedOpFactory(_OpFactory):
|
|
241
241
|
return InterpolatedDenseOp(target_op, self.base_interpolator, self.aux_interpolator, self.to_vector(),
|
242
242
|
_np.array(args), self._argument_indices)
|
243
243
|
|
244
|
-
#def write(self, dirname):
|
245
|
-
# dirname = _pathlib.Path(dirname)
|
246
|
-
# with open(str(dirname / "targetop.pkl"), 'wb') as f:
|
247
|
-
# _pickle.dump(self.target_op, f)
|
248
|
-
# _np.save(dirname / "paramvec.np", self._paramvec_with_time)
|
249
|
-
# self.base_interpolator.write(dirname / "base.interp")
|
250
|
-
# if self.aux_interpolator is not None:
|
251
|
-
# self.aux_interptolator.write(dirname / "aux.interp")
|
252
|
-
|
253
244
|
@property
|
254
245
|
def num_params(self):
|
255
246
|
return len(self._paramvec)
|
@@ -267,24 +258,6 @@ class InterpolatedOpFactory(_OpFactory):
|
|
267
258
|
|
268
259
|
class InterpolatedDenseOp(_DenseOperator):
|
269
260
|
|
270
|
-
#@classmethod
|
271
|
-
#def from_dir(cls, dirname):
|
272
|
-
# dirname = _pathlib.Path(dirname)
|
273
|
-
# with open(str(dirname / "targetop.pkl"), 'rb') as f:
|
274
|
-
# target_op = _pickle.load(f)
|
275
|
-
# pt = _np.load(dirname / "paramvec.np")
|
276
|
-
# base_interp = InterpolatedQuantity.from_file(dirname / "base.interp")
|
277
|
-
# aux_interp = InterpolatedQuantity.from_file(dirname / "aux.interp") \
|
278
|
-
# if (dirname / "aux.interp").exists() else None
|
279
|
-
#
|
280
|
-
# if base_interp.times is not None:
|
281
|
-
# tm = pt[-1]
|
282
|
-
# pt = pt[0:-1]
|
283
|
-
# else:
|
284
|
-
# tm = None
|
285
|
-
#
|
286
|
-
# return cls(target_op, base_interp, aux_interp, pt, tm)
|
287
|
-
|
288
261
|
@classmethod
|
289
262
|
def create_by_interpolating_physical_process(cls, target_op, physical_process, parameter_ranges=None,
|
290
263
|
parameter_points=None, comm=None,
|
@@ -391,15 +364,6 @@ class InterpolatedDenseOp(_DenseOperator):
|
|
391
364
|
# initialize object
|
392
365
|
self.from_vector(self._paramvec)
|
393
366
|
|
394
|
-
#def write(self, dirname):
|
395
|
-
# dirname = _pathlib.Path(dirname)
|
396
|
-
# with open(str(dirname / "targetop.pkl"), 'wb') as f:
|
397
|
-
# _pickle.dump(self.target_op, f)
|
398
|
-
# _np.save(dirname / "paramvec.np", self._paramvec_with_time)
|
399
|
-
# self.base_interpolator.write(dirname / "base.interp")
|
400
|
-
# if self.aux_interpolator is not None:
|
401
|
-
# self.aux_interptolator.write(dirname / "aux.interp")
|
402
|
-
|
403
367
|
@property
|
404
368
|
def num_params(self):
|
405
369
|
return len(self._paramvec)
|