pyGSTi 0.9.12__cp38-cp38-win32.whl → 0.9.13__cp38-cp38-win32.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) hide show
  1. pyGSTi-0.9.13.dist-info/METADATA +185 -0
  2. {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/RECORD +211 -220
  3. {pyGSTi-0.9.12.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 +62 -35
  7. pygsti/algorithms/fiducialpairreduction.py +95 -110
  8. pygsti/algorithms/fiducialselection.py +17 -8
  9. pygsti/algorithms/gaugeopt.py +2 -2
  10. pygsti/algorithms/germselection.py +87 -77
  11. pygsti/algorithms/mirroring.py +0 -388
  12. pygsti/algorithms/randomcircuit.py +165 -1333
  13. pygsti/algorithms/rbfit.py +0 -234
  14. pygsti/baseobjs/basis.py +94 -396
  15. pygsti/baseobjs/errorgenbasis.py +0 -132
  16. pygsti/baseobjs/errorgenspace.py +0 -10
  17. pygsti/baseobjs/label.py +52 -168
  18. pygsti/baseobjs/opcalc/fastopcalc.cp38-win32.pyd +0 -0
  19. pygsti/baseobjs/opcalc/fastopcalc.pyx +2 -2
  20. pygsti/baseobjs/polynomial.py +13 -595
  21. pygsti/baseobjs/protectedarray.py +72 -132
  22. pygsti/baseobjs/statespace.py +1 -0
  23. pygsti/circuits/__init__.py +1 -1
  24. pygsti/circuits/circuit.py +753 -504
  25. pygsti/circuits/circuitconstruction.py +0 -4
  26. pygsti/circuits/circuitlist.py +47 -5
  27. pygsti/circuits/circuitparser/__init__.py +8 -8
  28. pygsti/circuits/circuitparser/fastcircuitparser.cp38-win32.pyd +0 -0
  29. pygsti/circuits/circuitstructure.py +3 -3
  30. pygsti/circuits/cloudcircuitconstruction.py +27 -14
  31. pygsti/data/datacomparator.py +4 -9
  32. pygsti/data/dataset.py +51 -46
  33. pygsti/data/hypothesistest.py +0 -7
  34. pygsti/drivers/bootstrap.py +0 -49
  35. pygsti/drivers/longsequence.py +46 -10
  36. pygsti/evotypes/basereps_cython.cp38-win32.pyd +0 -0
  37. pygsti/evotypes/chp/opreps.py +0 -61
  38. pygsti/evotypes/chp/statereps.py +0 -32
  39. pygsti/evotypes/densitymx/effectcreps.cpp +9 -10
  40. pygsti/evotypes/densitymx/effectreps.cp38-win32.pyd +0 -0
  41. pygsti/evotypes/densitymx/effectreps.pyx +1 -1
  42. pygsti/evotypes/densitymx/opreps.cp38-win32.pyd +0 -0
  43. pygsti/evotypes/densitymx/opreps.pyx +2 -2
  44. pygsti/evotypes/densitymx/statereps.cp38-win32.pyd +0 -0
  45. pygsti/evotypes/densitymx/statereps.pyx +1 -1
  46. pygsti/evotypes/densitymx_slow/effectreps.py +7 -23
  47. pygsti/evotypes/densitymx_slow/opreps.py +16 -23
  48. pygsti/evotypes/densitymx_slow/statereps.py +10 -3
  49. pygsti/evotypes/evotype.py +39 -2
  50. pygsti/evotypes/stabilizer/effectreps.cp38-win32.pyd +0 -0
  51. pygsti/evotypes/stabilizer/effectreps.pyx +0 -4
  52. pygsti/evotypes/stabilizer/opreps.cp38-win32.pyd +0 -0
  53. pygsti/evotypes/stabilizer/opreps.pyx +0 -4
  54. pygsti/evotypes/stabilizer/statereps.cp38-win32.pyd +0 -0
  55. pygsti/evotypes/stabilizer/statereps.pyx +1 -5
  56. pygsti/evotypes/stabilizer/termreps.cp38-win32.pyd +0 -0
  57. pygsti/evotypes/stabilizer/termreps.pyx +0 -7
  58. pygsti/evotypes/stabilizer_slow/effectreps.py +0 -22
  59. pygsti/evotypes/stabilizer_slow/opreps.py +0 -4
  60. pygsti/evotypes/stabilizer_slow/statereps.py +0 -4
  61. pygsti/evotypes/statevec/effectreps.cp38-win32.pyd +0 -0
  62. pygsti/evotypes/statevec/effectreps.pyx +1 -1
  63. pygsti/evotypes/statevec/opreps.cp38-win32.pyd +0 -0
  64. pygsti/evotypes/statevec/opreps.pyx +2 -2
  65. pygsti/evotypes/statevec/statereps.cp38-win32.pyd +0 -0
  66. pygsti/evotypes/statevec/statereps.pyx +1 -1
  67. pygsti/evotypes/statevec/termreps.cp38-win32.pyd +0 -0
  68. pygsti/evotypes/statevec/termreps.pyx +0 -7
  69. pygsti/evotypes/statevec_slow/effectreps.py +0 -3
  70. pygsti/evotypes/statevec_slow/opreps.py +0 -5
  71. pygsti/extras/__init__.py +0 -1
  72. pygsti/extras/drift/signal.py +1 -1
  73. pygsti/extras/drift/stabilityanalyzer.py +3 -1
  74. pygsti/extras/interpygate/__init__.py +12 -0
  75. pygsti/extras/interpygate/core.py +0 -36
  76. pygsti/extras/interpygate/process_tomography.py +44 -10
  77. pygsti/extras/rpe/rpeconstruction.py +0 -2
  78. pygsti/forwardsims/__init__.py +1 -0
  79. pygsti/forwardsims/forwardsim.py +50 -93
  80. pygsti/forwardsims/mapforwardsim.py +78 -20
  81. pygsti/forwardsims/mapforwardsim_calc_densitymx.cp38-win32.pyd +0 -0
  82. pygsti/forwardsims/mapforwardsim_calc_densitymx.pyx +65 -66
  83. pygsti/forwardsims/mapforwardsim_calc_generic.py +91 -13
  84. pygsti/forwardsims/matrixforwardsim.py +72 -17
  85. pygsti/forwardsims/termforwardsim.py +9 -111
  86. pygsti/forwardsims/termforwardsim_calc_stabilizer.cp38-win32.pyd +0 -0
  87. pygsti/forwardsims/termforwardsim_calc_statevec.cp38-win32.pyd +0 -0
  88. pygsti/forwardsims/termforwardsim_calc_statevec.pyx +0 -651
  89. pygsti/forwardsims/torchfwdsim.py +265 -0
  90. pygsti/forwardsims/weakforwardsim.py +2 -2
  91. pygsti/io/__init__.py +1 -2
  92. pygsti/io/mongodb.py +0 -2
  93. pygsti/io/stdinput.py +6 -22
  94. pygsti/layouts/copalayout.py +10 -12
  95. pygsti/layouts/distlayout.py +0 -40
  96. pygsti/layouts/maplayout.py +103 -25
  97. pygsti/layouts/matrixlayout.py +99 -60
  98. pygsti/layouts/prefixtable.py +1534 -52
  99. pygsti/layouts/termlayout.py +1 -1
  100. pygsti/modelmembers/instruments/instrument.py +3 -3
  101. pygsti/modelmembers/instruments/tpinstrument.py +2 -2
  102. pygsti/modelmembers/modelmember.py +0 -17
  103. pygsti/modelmembers/operations/__init__.py +3 -4
  104. pygsti/modelmembers/operations/affineshiftop.py +206 -0
  105. pygsti/modelmembers/operations/composederrorgen.py +1 -1
  106. pygsti/modelmembers/operations/composedop.py +1 -24
  107. pygsti/modelmembers/operations/denseop.py +5 -5
  108. pygsti/modelmembers/operations/eigpdenseop.py +2 -2
  109. pygsti/modelmembers/operations/embeddederrorgen.py +1 -1
  110. pygsti/modelmembers/operations/embeddedop.py +0 -1
  111. pygsti/modelmembers/operations/experrorgenop.py +5 -2
  112. pygsti/modelmembers/operations/fullarbitraryop.py +1 -0
  113. pygsti/modelmembers/operations/fullcptpop.py +2 -2
  114. pygsti/modelmembers/operations/fulltpop.py +28 -6
  115. pygsti/modelmembers/operations/fullunitaryop.py +5 -4
  116. pygsti/modelmembers/operations/lindbladcoefficients.py +93 -78
  117. pygsti/modelmembers/operations/lindbladerrorgen.py +268 -441
  118. pygsti/modelmembers/operations/linearop.py +7 -27
  119. pygsti/modelmembers/operations/opfactory.py +1 -1
  120. pygsti/modelmembers/operations/repeatedop.py +1 -24
  121. pygsti/modelmembers/operations/staticstdop.py +1 -1
  122. pygsti/modelmembers/povms/__init__.py +3 -3
  123. pygsti/modelmembers/povms/basepovm.py +7 -36
  124. pygsti/modelmembers/povms/complementeffect.py +4 -9
  125. pygsti/modelmembers/povms/composedeffect.py +0 -320
  126. pygsti/modelmembers/povms/computationaleffect.py +1 -1
  127. pygsti/modelmembers/povms/computationalpovm.py +3 -1
  128. pygsti/modelmembers/povms/effect.py +3 -5
  129. pygsti/modelmembers/povms/marginalizedpovm.py +3 -81
  130. pygsti/modelmembers/povms/tppovm.py +74 -2
  131. pygsti/modelmembers/states/__init__.py +2 -5
  132. pygsti/modelmembers/states/composedstate.py +0 -317
  133. pygsti/modelmembers/states/computationalstate.py +3 -3
  134. pygsti/modelmembers/states/cptpstate.py +4 -4
  135. pygsti/modelmembers/states/densestate.py +10 -8
  136. pygsti/modelmembers/states/fullpurestate.py +0 -24
  137. pygsti/modelmembers/states/purestate.py +1 -1
  138. pygsti/modelmembers/states/state.py +5 -6
  139. pygsti/modelmembers/states/tpstate.py +28 -10
  140. pygsti/modelmembers/term.py +3 -6
  141. pygsti/modelmembers/torchable.py +50 -0
  142. pygsti/modelpacks/_modelpack.py +1 -1
  143. pygsti/modelpacks/smq1Q_ZN.py +3 -1
  144. pygsti/modelpacks/smq2Q_XXYYII.py +2 -1
  145. pygsti/modelpacks/smq2Q_XY.py +3 -3
  146. pygsti/modelpacks/smq2Q_XYI.py +2 -2
  147. pygsti/modelpacks/smq2Q_XYICNOT.py +3 -3
  148. pygsti/modelpacks/smq2Q_XYICPHASE.py +3 -3
  149. pygsti/modelpacks/smq2Q_XYXX.py +1 -1
  150. pygsti/modelpacks/smq2Q_XYZICNOT.py +3 -3
  151. pygsti/modelpacks/smq2Q_XYZZ.py +1 -1
  152. pygsti/modelpacks/stdtarget.py +0 -121
  153. pygsti/models/cloudnoisemodel.py +1 -2
  154. pygsti/models/explicitcalc.py +3 -3
  155. pygsti/models/explicitmodel.py +3 -13
  156. pygsti/models/fogistore.py +5 -3
  157. pygsti/models/localnoisemodel.py +1 -2
  158. pygsti/models/memberdict.py +0 -12
  159. pygsti/models/model.py +801 -68
  160. pygsti/models/modelconstruction.py +4 -4
  161. pygsti/models/modelnoise.py +2 -2
  162. pygsti/models/modelparaminterposer.py +1 -1
  163. pygsti/models/oplessmodel.py +1 -1
  164. pygsti/models/qutrit.py +15 -14
  165. pygsti/objectivefns/objectivefns.py +75 -140
  166. pygsti/objectivefns/wildcardbudget.py +2 -7
  167. pygsti/optimize/__init__.py +1 -0
  168. pygsti/optimize/arraysinterface.py +28 -0
  169. pygsti/optimize/customcg.py +0 -12
  170. pygsti/optimize/customlm.py +129 -323
  171. pygsti/optimize/customsolve.py +2 -2
  172. pygsti/optimize/optimize.py +0 -84
  173. pygsti/optimize/simplerlm.py +841 -0
  174. pygsti/optimize/wildcardopt.py +19 -598
  175. pygsti/protocols/confidenceregionfactory.py +28 -14
  176. pygsti/protocols/estimate.py +31 -14
  177. pygsti/protocols/gst.py +238 -142
  178. pygsti/protocols/modeltest.py +19 -12
  179. pygsti/protocols/protocol.py +9 -37
  180. pygsti/protocols/rb.py +450 -79
  181. pygsti/protocols/treenode.py +8 -2
  182. pygsti/protocols/vb.py +108 -206
  183. pygsti/protocols/vbdataframe.py +1 -1
  184. pygsti/report/factory.py +0 -15
  185. pygsti/report/fogidiagram.py +1 -17
  186. pygsti/report/modelfunction.py +12 -3
  187. pygsti/report/mpl_colormaps.py +1 -1
  188. pygsti/report/plothelpers.py +11 -3
  189. pygsti/report/report.py +16 -0
  190. pygsti/report/reportables.py +41 -37
  191. pygsti/report/templates/offline/pygsti_dashboard.css +6 -0
  192. pygsti/report/templates/offline/pygsti_dashboard.js +12 -0
  193. pygsti/report/workspace.py +2 -14
  194. pygsti/report/workspaceplots.py +328 -505
  195. pygsti/tools/basistools.py +9 -36
  196. pygsti/tools/edesigntools.py +124 -96
  197. pygsti/tools/fastcalc.cp38-win32.pyd +0 -0
  198. pygsti/tools/fastcalc.pyx +35 -81
  199. pygsti/tools/internalgates.py +151 -15
  200. pygsti/tools/jamiolkowski.py +5 -5
  201. pygsti/tools/lindbladtools.py +19 -11
  202. pygsti/tools/listtools.py +0 -114
  203. pygsti/tools/matrixmod2.py +1 -1
  204. pygsti/tools/matrixtools.py +173 -339
  205. pygsti/tools/nameddict.py +1 -1
  206. pygsti/tools/optools.py +154 -88
  207. pygsti/tools/pdftools.py +0 -25
  208. pygsti/tools/rbtheory.py +3 -320
  209. pygsti/tools/slicetools.py +64 -12
  210. pyGSTi-0.9.12.dist-info/METADATA +0 -157
  211. pygsti/algorithms/directx.py +0 -711
  212. pygsti/evotypes/qibo/__init__.py +0 -33
  213. pygsti/evotypes/qibo/effectreps.py +0 -78
  214. pygsti/evotypes/qibo/opreps.py +0 -376
  215. pygsti/evotypes/qibo/povmreps.py +0 -98
  216. pygsti/evotypes/qibo/statereps.py +0 -174
  217. pygsti/extras/rb/__init__.py +0 -13
  218. pygsti/extras/rb/benchmarker.py +0 -957
  219. pygsti/extras/rb/dataset.py +0 -378
  220. pygsti/extras/rb/io.py +0 -814
  221. pygsti/extras/rb/simulate.py +0 -1020
  222. pygsti/io/legacyio.py +0 -385
  223. pygsti/modelmembers/povms/denseeffect.py +0 -142
  224. {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/LICENSE +0 -0
  225. {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/top_level.txt +0 -0
@@ -15,7 +15,6 @@ import numpy as _np
15
15
 
16
16
  from pygsti.baseobjs import _compatibility as _compat
17
17
 
18
-
19
18
  class ProtectedArray(object):
20
19
  """
21
20
  A numpy ndarray-like class that allows certain elements to be treated as read-only.
@@ -25,39 +24,63 @@ class ProtectedArray(object):
25
24
  input_array : numpy.ndarray
26
25
  The base array.
27
26
 
28
- indices_to_protect : tuple or list, optional
29
- A list or tuple of length `input_array.shape`, specifying
27
+ indices_to_protect : int or list of tuples, optional
28
+ A list of length `input_array.shape`, specifying
30
29
  the indices to protect along each axis. Values may be
31
30
  integers, slices, or lists of integers,
32
31
  e.g. `(0, slice(None, None, None))`.
32
+ Also supported are iterables over tuples/lists, each
33
+ of length `input_array.shape`, specifying
34
+ the indices to protect along each axis.
35
+
36
+ protected_index_mask : numpy.ndarray, optional
37
+ An optional array with the same shape as `input_array` which if
38
+ specified is used to initialize the mask for protected indices
39
+ used by this array. Note that is specified the value overrides
40
+ any specification given in indices_to_protect, meaning that argument
41
+ is ignored.
33
42
  """
34
43
 
35
- def __init__(self, input_array, indices_to_protect=None):
44
+ def __init__(self, input_array, indices_to_protect=None, protected_index_mask= None):
36
45
  self.base = input_array
37
46
 
38
- #Get protected indices, a specified as:
39
- self.indicesToProtect = []
40
- if indices_to_protect is not None:
41
- if not isinstance(indices_to_protect, (list, tuple)):
42
- indices_to_protect = (indices_to_protect,)
43
-
44
- assert(len(indices_to_protect) <= len(self.base.shape))
45
- for ky, L in zip(indices_to_protect, self.base.shape):
46
- if isinstance(ky, slice):
47
- pindices = range(*ky.indices(L))
48
- elif _compat.isint(ky):
49
- i = ky + L if ky < 0 else ky
50
- if i < 0 or i > L:
51
- raise IndexError("index (%d) is out of range." % ky)
52
- pindices = (i,)
53
- elif isinstance(ky, list):
54
- pindices = ky
55
- else: raise TypeError("Invalid index type: %s" % type(ky))
56
- self.indicesToProtect.append(pindices)
57
-
58
- if len(self.indicesToProtect) == 0:
59
- self.indicesToProtect = None
60
-
47
+ if protected_index_mask is not None:
48
+ #check this has the correct shape
49
+ assert protected_index_mask.shape == input_array.shape
50
+
51
+ #Cast this to a binary dtype (to save space since we only
52
+ #need boolean values).
53
+ self.protected_index_mask = protected_index_mask.astype(_np.bool_)
54
+
55
+ #otherwise use the value passed into indices to protect to construct
56
+ #a mask.
57
+ #add in support for multiple sets of indices to protect
58
+ #by allowing a nested iterable format. Do this by forcing
59
+ #everything into this format and then looping over the nested
60
+ #submembers.
61
+ elif indices_to_protect is not None:
62
+ if isinstance(indices_to_protect, int):
63
+ indices_to_protect= [(indices_to_protect,)]
64
+ #if this is a list go through and wrap any integers
65
+ #at the top level in a tuple.
66
+ elif isinstance(indices_to_protect, (list, tuple)):
67
+ #check whether this is a single-level tuple/list corresponding
68
+ #containing only ints and/or slices. If so wrap this in a list.
69
+ if all([isinstance(idx, (int, slice)) for idx in indices_to_protect]):
70
+ indices_to_protect = [indices_to_protect]
71
+
72
+ #add some logic for mixing of unwrapped top-level ints and tuples/lists.
73
+ indices_to_protect = [tuple(indices) if isinstance(indices, (list, tuple)) else (indices,) for indices in indices_to_protect]
74
+ #initialize an empty mask
75
+ self.protected_index_mask = _np.zeros(input_array.shape , dtype= _np.bool_)
76
+
77
+ #now loop over the nested subelements and add them to the mask:
78
+ for indices in indices_to_protect:
79
+ assert(len(indices) <= len(self.base.shape))
80
+ self.protected_index_mask[indices]=1
81
+ #otherwise set the mask to all zeros.
82
+ else:
83
+ self.protected_index_mask = _np.zeros(input_array.shape , dtype= _np.bool_)
61
84
  #Note: no need to set self.base.flags.writeable = True anymore,
62
85
  # since this flag can only apply to a data owner as of numpy 1.16 or so.
63
86
  # Instead, we just copy the data whenever we return a readonly array.
@@ -102,7 +125,7 @@ class ProtectedArray(object):
102
125
  self.__dict__.update(state)
103
126
 
104
127
  #Access to underlying ndarray
105
-
128
+
106
129
  def __getattr__(self, attr):
107
130
  # set references to our memory as (entirely) read-only
108
131
  ret = getattr(self.__dict__['base'], attr)
@@ -116,115 +139,32 @@ class ProtectedArray(object):
116
139
  return self.__getitem__(slice(i, j))
117
140
 
118
141
  def __getitem__(self, key):
142
+ #Use key to extract subarray of self.base and self.protected_index_mask
143
+ ret = self.base[key]
144
+ new_protected_mask = self.protected_index_mask[key]
119
145
 
120
- writeable = True
121
-
122
- #check if key matches/overlaps protected region
123
- if self.indicesToProtect is not None:
124
- new_indicesToProtect = []; nUnprotectedIndices = 0
125
- tup_key = key if isinstance(key, tuple) else (key,)
126
-
127
- while len(tup_key) < len(self.base.shape):
128
- tup_key = tup_key + (slice(None, None, None),)
129
-
130
- for ky, pindices, L in zip(tup_key, self.indicesToProtect, self.base.shape):
131
-
132
- #Get requested indices
133
- if isinstance(ky, slice):
134
- indices = range(*ky.indices(L))
135
-
136
- new_pindices = []
137
- for ii, i in enumerate(indices):
138
- if i in pindices:
139
- new_pindices.append(ii) # index of i within indices
140
- new_pindices = sorted(list(set(new_pindices)))
141
- new_indicesToProtect.append(new_pindices)
142
-
143
- #tally how many indices in this dimension are unprotected
144
- nTotalInDim = len(indices)
145
- nUnprotectedInCurDim = (len(indices) - len(new_pindices))
146
-
147
- elif _compat.isint(ky):
148
- i = ky + L if ky < 0 else ky
149
- if i > L:
150
- raise IndexError("The index (%d) is out of range." % ky)
151
-
152
- nTotalInDim = 1
153
- if i not in pindices: # single index that is unprotected => all unprotected
154
- nUnprotectedInCurDim = 1 # a single unprotected index
155
- else:
156
- nUnprotectedInCurDim = 0
157
-
158
- else: raise TypeError("Invalid index type: %s" % type(ky))
159
-
160
- nUnprotectedIndices += nUnprotectedInCurDim
161
-
162
- #if there exists a single dimension with no protected indices, then
163
- # the whole array is writeable.
164
- if nTotalInDim == nUnprotectedInCurDim:
165
- writeable = True
166
- new_indicesToProtect = None
167
- break
168
-
169
- else:
170
- # if we didn't break b/c of above block, which means each dim has
171
- # at least one protected index
172
-
173
- #if there are no unprotected indices, then just set writeable == False
174
- if nUnprotectedIndices == 0:
175
- writeable = False
176
- new_indicesToProtect = None
177
- else:
178
- #There is at least one writeable (unprotected) index in some dimension
179
- # and at least one protected index in *every* dimension. We need to
180
- # set indicesToProtect to describe what to protect
181
- assert(len(new_indicesToProtect) > 0) # b/c otherwise another case would hold
182
- writeable = True
183
- new_indicesToProtect = tuple(new_indicesToProtect)
184
-
185
- else: # (if nothing is protected)
186
- writeable = True
187
- new_indicesToProtect = None
188
-
189
- ret = _np.ndarray.__getitem__(self.base, key)
190
-
146
+ #If ret is not a scalar return a new ProtectedArray corresponding to the
147
+ #selected subarray with the set of protected indices inherited over from the
148
+ #original.
191
149
  if not _np.isscalar(ret):
192
- if writeable: # then some of the indices are writeable
193
- ret = ProtectedArray(ret)
194
- ret.indicesToProtect = new_indicesToProtect
195
- else:
150
+ if not _np.all(new_protected_mask): # then some of the indices are writeable
151
+ ret = ProtectedArray(ret, protected_index_mask= new_protected_mask)
152
+ else: #otherwise all of the values are masked off.
196
153
  ret = _np.require(ret.copy(), requirements=['OWNDATA']) # copy to a new read-only array
197
154
  ret.flags.writeable = False # a read-only array
198
- ret = ProtectedArray(ret) # return a ProtectedArray that is read-only
199
-
200
- #print " writeable = ",ret.flags.writeable
201
- #print " new_toProtect = ",ret.indicesToProtect
202
- #print "<< END getitem"
155
+ ret = ProtectedArray(ret, protected_index_mask=new_protected_mask) # return a ProtectedArray that is read-only
203
156
  return ret
204
157
 
205
158
  def __setitem__(self, key, val):
206
- #print "In setitem with key = ", key, "val = ",val
207
-
208
- protectionViolation = [] # per dimension
209
- if self.indicesToProtect is not None:
210
- tup_key = key if isinstance(key, tuple) else (key,)
211
- for ky, pindices, L in zip(tup_key, self.indicesToProtect, self.base.shape):
212
-
213
- #Get requested indices
214
- if isinstance(ky, slice):
215
- indices = range(*ky.indices(L))
216
- if any(i in pindices for i in indices):
217
- protectionViolation.append(True)
218
- else: protectionViolation.append(False)
219
-
220
- elif _compat.isint(ky):
221
- i = ky + L if ky < 0 else ky
222
- if i > L:
223
- raise IndexError("The index (%d) is out of range." % ky)
224
- protectionViolation.append(i in pindices)
225
-
226
- else: raise TypeError("Invalid index type: %s" % type(ky))
227
-
228
- if all(protectionViolation): # assigns to a protected index in each dim
229
- raise ValueError("**assignment destination is read-only")
159
+ #check if any of the indices in key have been masked off.
160
+ if _np.any(self.protected_index_mask[key]): # assigns to a protected index in each dim
161
+ raise ValueError("**some or all of assignment destination is read-only")
162
+ #not sure what the original logic was for this return statement, but I don't see any
163
+ #harm in keeping it.
230
164
  return self.base.__setitem__(key, val)
165
+
166
+ #add a repr method that prints the base array, which is typically what
167
+ #we want.
168
+ def __repr__(self):
169
+ return _np.array2string(self.base)
170
+
@@ -1274,6 +1274,7 @@ class ExplicitStateSpace(StateSpace):
1274
1274
  ['*'.join(["%s(%d%s)" % (lbl, self.label_dims[lbl], 'c' if (self.label_types[lbl] == 'C') else '')
1275
1275
  for lbl in tpb]) for tpb in self.labels])
1276
1276
 
1277
+
1277
1278
  def default_space_for_dim(dim):
1278
1279
  """
1279
1280
  Create a state space for a given superoperator dimension.
@@ -10,7 +10,7 @@ A sub-package holding circuit-related objects
10
10
  # http://www.apache.org/licenses/LICENSE-2.0 or in the LICENSE file in the root pyGSTi directory.
11
11
  #***************************************************************************************************
12
12
 
13
- from .circuit import Circuit
13
+ from .circuit import Circuit, SeparatePOVMCircuit
14
14
  from .circuitlist import CircuitList
15
15
  from .circuitstructure import CircuitPlaquette, FiducialPairPlaquette, \
16
16
  GermFiducialPairPlaquette, PlaquetteGridCircuitStructure