pyGSTi 0.9.12.1__cp39-cp39-win32.whl → 0.9.13__cp39-cp39-win32.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. pyGSTi-0.9.13.dist-info/METADATA +197 -0
  2. {pyGSTi-0.9.12.1.dist-info → pyGSTi-0.9.13.dist-info}/RECORD +207 -217
  3. {pyGSTi-0.9.12.1.dist-info → pyGSTi-0.9.13.dist-info}/WHEEL +1 -1
  4. pygsti/_version.py +2 -2
  5. pygsti/algorithms/contract.py +1 -1
  6. pygsti/algorithms/core.py +42 -28
  7. pygsti/algorithms/fiducialselection.py +17 -8
  8. pygsti/algorithms/gaugeopt.py +2 -2
  9. pygsti/algorithms/germselection.py +87 -77
  10. pygsti/algorithms/mirroring.py +0 -388
  11. pygsti/algorithms/randomcircuit.py +165 -1333
  12. pygsti/algorithms/rbfit.py +0 -234
  13. pygsti/baseobjs/basis.py +94 -396
  14. pygsti/baseobjs/errorgenbasis.py +0 -132
  15. pygsti/baseobjs/errorgenspace.py +0 -10
  16. pygsti/baseobjs/label.py +52 -168
  17. pygsti/baseobjs/opcalc/fastopcalc.cp39-win32.pyd +0 -0
  18. pygsti/baseobjs/opcalc/fastopcalc.pyx +2 -2
  19. pygsti/baseobjs/polynomial.py +13 -595
  20. pygsti/baseobjs/statespace.py +1 -0
  21. pygsti/circuits/__init__.py +1 -1
  22. pygsti/circuits/circuit.py +682 -505
  23. pygsti/circuits/circuitconstruction.py +0 -4
  24. pygsti/circuits/circuitlist.py +47 -5
  25. pygsti/circuits/circuitparser/__init__.py +8 -8
  26. pygsti/circuits/circuitparser/fastcircuitparser.cp39-win32.pyd +0 -0
  27. pygsti/circuits/circuitstructure.py +3 -3
  28. pygsti/circuits/cloudcircuitconstruction.py +1 -1
  29. pygsti/data/datacomparator.py +2 -7
  30. pygsti/data/dataset.py +46 -44
  31. pygsti/data/hypothesistest.py +0 -7
  32. pygsti/drivers/bootstrap.py +0 -49
  33. pygsti/drivers/longsequence.py +2 -1
  34. pygsti/evotypes/basereps_cython.cp39-win32.pyd +0 -0
  35. pygsti/evotypes/chp/opreps.py +0 -61
  36. pygsti/evotypes/chp/statereps.py +0 -32
  37. pygsti/evotypes/densitymx/effectcreps.cpp +9 -10
  38. pygsti/evotypes/densitymx/effectreps.cp39-win32.pyd +0 -0
  39. pygsti/evotypes/densitymx/effectreps.pyx +1 -1
  40. pygsti/evotypes/densitymx/opreps.cp39-win32.pyd +0 -0
  41. pygsti/evotypes/densitymx/opreps.pyx +2 -2
  42. pygsti/evotypes/densitymx/statereps.cp39-win32.pyd +0 -0
  43. pygsti/evotypes/densitymx/statereps.pyx +1 -1
  44. pygsti/evotypes/densitymx_slow/effectreps.py +7 -23
  45. pygsti/evotypes/densitymx_slow/opreps.py +16 -23
  46. pygsti/evotypes/densitymx_slow/statereps.py +10 -3
  47. pygsti/evotypes/evotype.py +39 -2
  48. pygsti/evotypes/stabilizer/effectreps.cp39-win32.pyd +0 -0
  49. pygsti/evotypes/stabilizer/effectreps.pyx +0 -4
  50. pygsti/evotypes/stabilizer/opreps.cp39-win32.pyd +0 -0
  51. pygsti/evotypes/stabilizer/opreps.pyx +0 -4
  52. pygsti/evotypes/stabilizer/statereps.cp39-win32.pyd +0 -0
  53. pygsti/evotypes/stabilizer/statereps.pyx +1 -5
  54. pygsti/evotypes/stabilizer/termreps.cp39-win32.pyd +0 -0
  55. pygsti/evotypes/stabilizer/termreps.pyx +0 -7
  56. pygsti/evotypes/stabilizer_slow/effectreps.py +0 -22
  57. pygsti/evotypes/stabilizer_slow/opreps.py +0 -4
  58. pygsti/evotypes/stabilizer_slow/statereps.py +0 -4
  59. pygsti/evotypes/statevec/effectreps.cp39-win32.pyd +0 -0
  60. pygsti/evotypes/statevec/effectreps.pyx +1 -1
  61. pygsti/evotypes/statevec/opreps.cp39-win32.pyd +0 -0
  62. pygsti/evotypes/statevec/opreps.pyx +2 -2
  63. pygsti/evotypes/statevec/statereps.cp39-win32.pyd +0 -0
  64. pygsti/evotypes/statevec/statereps.pyx +1 -1
  65. pygsti/evotypes/statevec/termreps.cp39-win32.pyd +0 -0
  66. pygsti/evotypes/statevec/termreps.pyx +0 -7
  67. pygsti/evotypes/statevec_slow/effectreps.py +0 -3
  68. pygsti/evotypes/statevec_slow/opreps.py +0 -5
  69. pygsti/extras/__init__.py +0 -1
  70. pygsti/extras/drift/stabilityanalyzer.py +3 -1
  71. pygsti/extras/interpygate/__init__.py +12 -0
  72. pygsti/extras/interpygate/core.py +0 -36
  73. pygsti/extras/interpygate/process_tomography.py +44 -10
  74. pygsti/extras/rpe/rpeconstruction.py +0 -2
  75. pygsti/forwardsims/__init__.py +1 -0
  76. pygsti/forwardsims/forwardsim.py +14 -55
  77. pygsti/forwardsims/mapforwardsim.py +69 -18
  78. pygsti/forwardsims/mapforwardsim_calc_densitymx.cp39-win32.pyd +0 -0
  79. pygsti/forwardsims/mapforwardsim_calc_densitymx.pyx +65 -66
  80. pygsti/forwardsims/mapforwardsim_calc_generic.py +91 -13
  81. pygsti/forwardsims/matrixforwardsim.py +63 -15
  82. pygsti/forwardsims/termforwardsim.py +8 -110
  83. pygsti/forwardsims/termforwardsim_calc_stabilizer.cp39-win32.pyd +0 -0
  84. pygsti/forwardsims/termforwardsim_calc_statevec.cp39-win32.pyd +0 -0
  85. pygsti/forwardsims/termforwardsim_calc_statevec.pyx +0 -651
  86. pygsti/forwardsims/torchfwdsim.py +265 -0
  87. pygsti/forwardsims/weakforwardsim.py +2 -2
  88. pygsti/io/__init__.py +1 -2
  89. pygsti/io/mongodb.py +0 -2
  90. pygsti/io/stdinput.py +6 -22
  91. pygsti/layouts/copalayout.py +10 -12
  92. pygsti/layouts/distlayout.py +0 -40
  93. pygsti/layouts/maplayout.py +103 -25
  94. pygsti/layouts/matrixlayout.py +99 -60
  95. pygsti/layouts/prefixtable.py +1534 -52
  96. pygsti/layouts/termlayout.py +1 -1
  97. pygsti/modelmembers/instruments/instrument.py +3 -3
  98. pygsti/modelmembers/instruments/tpinstrument.py +2 -2
  99. pygsti/modelmembers/modelmember.py +0 -17
  100. pygsti/modelmembers/operations/__init__.py +2 -4
  101. pygsti/modelmembers/operations/affineshiftop.py +1 -0
  102. pygsti/modelmembers/operations/composederrorgen.py +1 -1
  103. pygsti/modelmembers/operations/composedop.py +1 -24
  104. pygsti/modelmembers/operations/denseop.py +5 -5
  105. pygsti/modelmembers/operations/eigpdenseop.py +2 -2
  106. pygsti/modelmembers/operations/embeddederrorgen.py +1 -1
  107. pygsti/modelmembers/operations/embeddedop.py +0 -1
  108. pygsti/modelmembers/operations/experrorgenop.py +2 -2
  109. pygsti/modelmembers/operations/fullarbitraryop.py +1 -0
  110. pygsti/modelmembers/operations/fullcptpop.py +2 -2
  111. pygsti/modelmembers/operations/fulltpop.py +28 -6
  112. pygsti/modelmembers/operations/fullunitaryop.py +5 -4
  113. pygsti/modelmembers/operations/lindbladcoefficients.py +93 -78
  114. pygsti/modelmembers/operations/lindbladerrorgen.py +268 -441
  115. pygsti/modelmembers/operations/linearop.py +7 -27
  116. pygsti/modelmembers/operations/opfactory.py +1 -1
  117. pygsti/modelmembers/operations/repeatedop.py +1 -24
  118. pygsti/modelmembers/operations/staticstdop.py +1 -1
  119. pygsti/modelmembers/povms/__init__.py +3 -3
  120. pygsti/modelmembers/povms/basepovm.py +7 -36
  121. pygsti/modelmembers/povms/complementeffect.py +4 -9
  122. pygsti/modelmembers/povms/composedeffect.py +0 -320
  123. pygsti/modelmembers/povms/computationaleffect.py +1 -1
  124. pygsti/modelmembers/povms/computationalpovm.py +3 -1
  125. pygsti/modelmembers/povms/effect.py +3 -5
  126. pygsti/modelmembers/povms/marginalizedpovm.py +0 -79
  127. pygsti/modelmembers/povms/tppovm.py +74 -2
  128. pygsti/modelmembers/states/__init__.py +2 -5
  129. pygsti/modelmembers/states/composedstate.py +0 -317
  130. pygsti/modelmembers/states/computationalstate.py +3 -3
  131. pygsti/modelmembers/states/cptpstate.py +4 -4
  132. pygsti/modelmembers/states/densestate.py +6 -4
  133. pygsti/modelmembers/states/fullpurestate.py +0 -24
  134. pygsti/modelmembers/states/purestate.py +1 -1
  135. pygsti/modelmembers/states/state.py +5 -6
  136. pygsti/modelmembers/states/tpstate.py +28 -10
  137. pygsti/modelmembers/term.py +3 -6
  138. pygsti/modelmembers/torchable.py +50 -0
  139. pygsti/modelpacks/_modelpack.py +1 -1
  140. pygsti/modelpacks/smq1Q_ZN.py +3 -1
  141. pygsti/modelpacks/smq2Q_XXYYII.py +2 -1
  142. pygsti/modelpacks/smq2Q_XY.py +3 -3
  143. pygsti/modelpacks/smq2Q_XYI.py +2 -2
  144. pygsti/modelpacks/smq2Q_XYICNOT.py +3 -3
  145. pygsti/modelpacks/smq2Q_XYICPHASE.py +3 -3
  146. pygsti/modelpacks/smq2Q_XYXX.py +1 -1
  147. pygsti/modelpacks/smq2Q_XYZICNOT.py +3 -3
  148. pygsti/modelpacks/smq2Q_XYZZ.py +1 -1
  149. pygsti/modelpacks/stdtarget.py +0 -121
  150. pygsti/models/cloudnoisemodel.py +1 -2
  151. pygsti/models/explicitcalc.py +3 -3
  152. pygsti/models/explicitmodel.py +3 -13
  153. pygsti/models/fogistore.py +5 -3
  154. pygsti/models/localnoisemodel.py +1 -2
  155. pygsti/models/memberdict.py +0 -12
  156. pygsti/models/model.py +800 -65
  157. pygsti/models/modelconstruction.py +4 -4
  158. pygsti/models/modelnoise.py +2 -2
  159. pygsti/models/modelparaminterposer.py +1 -1
  160. pygsti/models/oplessmodel.py +1 -1
  161. pygsti/models/qutrit.py +15 -14
  162. pygsti/objectivefns/objectivefns.py +73 -138
  163. pygsti/objectivefns/wildcardbudget.py +2 -7
  164. pygsti/optimize/__init__.py +1 -0
  165. pygsti/optimize/arraysinterface.py +28 -0
  166. pygsti/optimize/customcg.py +0 -12
  167. pygsti/optimize/customlm.py +129 -323
  168. pygsti/optimize/customsolve.py +2 -2
  169. pygsti/optimize/optimize.py +0 -84
  170. pygsti/optimize/simplerlm.py +841 -0
  171. pygsti/optimize/wildcardopt.py +19 -598
  172. pygsti/protocols/confidenceregionfactory.py +28 -14
  173. pygsti/protocols/estimate.py +31 -14
  174. pygsti/protocols/gst.py +142 -68
  175. pygsti/protocols/modeltest.py +6 -10
  176. pygsti/protocols/protocol.py +9 -37
  177. pygsti/protocols/rb.py +450 -79
  178. pygsti/protocols/treenode.py +8 -2
  179. pygsti/protocols/vb.py +108 -206
  180. pygsti/protocols/vbdataframe.py +1 -1
  181. pygsti/report/factory.py +0 -15
  182. pygsti/report/fogidiagram.py +1 -17
  183. pygsti/report/modelfunction.py +12 -3
  184. pygsti/report/mpl_colormaps.py +1 -1
  185. pygsti/report/plothelpers.py +8 -2
  186. pygsti/report/reportables.py +41 -37
  187. pygsti/report/templates/offline/pygsti_dashboard.css +6 -0
  188. pygsti/report/templates/offline/pygsti_dashboard.js +12 -0
  189. pygsti/report/workspace.py +2 -14
  190. pygsti/report/workspaceplots.py +326 -504
  191. pygsti/tools/basistools.py +9 -36
  192. pygsti/tools/edesigntools.py +124 -96
  193. pygsti/tools/fastcalc.cp39-win32.pyd +0 -0
  194. pygsti/tools/fastcalc.pyx +35 -81
  195. pygsti/tools/internalgates.py +151 -15
  196. pygsti/tools/jamiolkowski.py +5 -5
  197. pygsti/tools/lindbladtools.py +19 -11
  198. pygsti/tools/listtools.py +0 -114
  199. pygsti/tools/matrixmod2.py +1 -1
  200. pygsti/tools/matrixtools.py +173 -339
  201. pygsti/tools/nameddict.py +1 -1
  202. pygsti/tools/optools.py +154 -88
  203. pygsti/tools/pdftools.py +0 -25
  204. pygsti/tools/rbtheory.py +3 -320
  205. pygsti/tools/slicetools.py +64 -12
  206. pyGSTi-0.9.12.1.dist-info/METADATA +0 -155
  207. pygsti/algorithms/directx.py +0 -711
  208. pygsti/evotypes/qibo/__init__.py +0 -33
  209. pygsti/evotypes/qibo/effectreps.py +0 -78
  210. pygsti/evotypes/qibo/opreps.py +0 -376
  211. pygsti/evotypes/qibo/povmreps.py +0 -98
  212. pygsti/evotypes/qibo/statereps.py +0 -174
  213. pygsti/extras/rb/__init__.py +0 -13
  214. pygsti/extras/rb/benchmarker.py +0 -957
  215. pygsti/extras/rb/dataset.py +0 -378
  216. pygsti/extras/rb/io.py +0 -814
  217. pygsti/extras/rb/simulate.py +0 -1020
  218. pygsti/io/legacyio.py +0 -385
  219. pygsti/modelmembers/povms/denseeffect.py +0 -142
  220. {pyGSTi-0.9.12.1.dist-info → pyGSTi-0.9.13.dist-info}/LICENSE +0 -0
  221. {pyGSTi-0.9.12.1.dist-info → pyGSTi-0.9.13.dist-info}/top_level.txt +0 -0
@@ -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.product([fct.dim for fct in self.factor_reps])
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(_basereps.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(_basereps.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(_basereps.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
- assert(len(self.data) == self.state_space.dim)
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?)
@@ -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=False):
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
- elif obj == "default":
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)
@@ -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)
@@ -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
@@ -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.product([len(sf.pvectors) for sf in self.factor_reps]))
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),
@@ -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.
@@ -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.product(factor_dims)
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
@@ -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.product([num_basis_els[i] for i in action_inds]) == embedded_rep.dim), \
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.product(state_space.tensor_product_block_udimensions(k))
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
 
@@ -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.product([fct.dim for fct in self.factor_reps])
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
 
@@ -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
@@ -9,5 +9,4 @@
9
9
  """ Container for beyond-GST sub-packages """
10
10
 
11
11
  # from . import drift
12
- # from . import rb # temporarily removed until RB analysis is fixed
13
12
  # from . import rpe
@@ -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: powerlist = spectra[indices].copy()
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)