pyGSTi 0.9.12__cp39-cp39-win_amd64.whl → 0.9.13__cp39-cp39-win_amd64.whl
Sign up to get free protection for your applications and to get access to all the features.
- pyGSTi-0.9.13.dist-info/METADATA +197 -0
- {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/RECORD +211 -220
- {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/WHEEL +1 -1
- pygsti/_version.py +2 -2
- pygsti/algorithms/contract.py +1 -1
- pygsti/algorithms/core.py +62 -35
- pygsti/algorithms/fiducialpairreduction.py +95 -110
- pygsti/algorithms/fiducialselection.py +17 -8
- pygsti/algorithms/gaugeopt.py +2 -2
- pygsti/algorithms/germselection.py +87 -77
- pygsti/algorithms/mirroring.py +0 -388
- pygsti/algorithms/randomcircuit.py +165 -1333
- pygsti/algorithms/rbfit.py +0 -234
- pygsti/baseobjs/basis.py +94 -396
- pygsti/baseobjs/errorgenbasis.py +0 -132
- pygsti/baseobjs/errorgenspace.py +0 -10
- pygsti/baseobjs/label.py +52 -168
- pygsti/baseobjs/opcalc/fastopcalc.cp39-win_amd64.pyd +0 -0
- pygsti/baseobjs/opcalc/fastopcalc.pyx +2 -2
- pygsti/baseobjs/polynomial.py +13 -595
- pygsti/baseobjs/protectedarray.py +72 -132
- pygsti/baseobjs/statespace.py +1 -0
- pygsti/circuits/__init__.py +1 -1
- pygsti/circuits/circuit.py +753 -504
- pygsti/circuits/circuitconstruction.py +0 -4
- pygsti/circuits/circuitlist.py +47 -5
- pygsti/circuits/circuitparser/__init__.py +8 -8
- pygsti/circuits/circuitparser/fastcircuitparser.cp39-win_amd64.pyd +0 -0
- pygsti/circuits/circuitstructure.py +3 -3
- pygsti/circuits/cloudcircuitconstruction.py +27 -14
- pygsti/data/datacomparator.py +4 -9
- pygsti/data/dataset.py +51 -46
- pygsti/data/hypothesistest.py +0 -7
- pygsti/drivers/bootstrap.py +0 -49
- pygsti/drivers/longsequence.py +46 -10
- pygsti/evotypes/basereps_cython.cp39-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.cp39-win_amd64.pyd +0 -0
- pygsti/evotypes/densitymx/effectreps.pyx +1 -1
- pygsti/evotypes/densitymx/opreps.cp39-win_amd64.pyd +0 -0
- pygsti/evotypes/densitymx/opreps.pyx +2 -2
- pygsti/evotypes/densitymx/statereps.cp39-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.cp39-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/effectreps.pyx +0 -4
- pygsti/evotypes/stabilizer/opreps.cp39-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/opreps.pyx +0 -4
- pygsti/evotypes/stabilizer/statereps.cp39-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/statereps.pyx +1 -5
- pygsti/evotypes/stabilizer/termreps.cp39-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.cp39-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/effectreps.pyx +1 -1
- pygsti/evotypes/statevec/opreps.cp39-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/opreps.pyx +2 -2
- pygsti/evotypes/statevec/statereps.cp39-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/statereps.pyx +1 -1
- pygsti/evotypes/statevec/termreps.cp39-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/termreps.pyx +0 -7
- pygsti/evotypes/statevec_slow/effectreps.py +0 -3
- pygsti/evotypes/statevec_slow/opreps.py +0 -5
- pygsti/extras/__init__.py +0 -1
- pygsti/extras/drift/signal.py +1 -1
- pygsti/extras/drift/stabilityanalyzer.py +3 -1
- pygsti/extras/interpygate/__init__.py +12 -0
- pygsti/extras/interpygate/core.py +0 -36
- pygsti/extras/interpygate/process_tomography.py +44 -10
- pygsti/extras/rpe/rpeconstruction.py +0 -2
- pygsti/forwardsims/__init__.py +1 -0
- pygsti/forwardsims/forwardsim.py +50 -93
- pygsti/forwardsims/mapforwardsim.py +78 -20
- pygsti/forwardsims/mapforwardsim_calc_densitymx.cp39-win_amd64.pyd +0 -0
- pygsti/forwardsims/mapforwardsim_calc_densitymx.pyx +65 -66
- pygsti/forwardsims/mapforwardsim_calc_generic.py +91 -13
- pygsti/forwardsims/matrixforwardsim.py +72 -17
- pygsti/forwardsims/termforwardsim.py +9 -111
- pygsti/forwardsims/termforwardsim_calc_stabilizer.cp39-win_amd64.pyd +0 -0
- pygsti/forwardsims/termforwardsim_calc_statevec.cp39-win_amd64.pyd +0 -0
- pygsti/forwardsims/termforwardsim_calc_statevec.pyx +0 -651
- pygsti/forwardsims/torchfwdsim.py +265 -0
- pygsti/forwardsims/weakforwardsim.py +2 -2
- pygsti/io/__init__.py +1 -2
- pygsti/io/mongodb.py +0 -2
- pygsti/io/stdinput.py +6 -22
- pygsti/layouts/copalayout.py +10 -12
- pygsti/layouts/distlayout.py +0 -40
- pygsti/layouts/maplayout.py +103 -25
- pygsti/layouts/matrixlayout.py +99 -60
- pygsti/layouts/prefixtable.py +1534 -52
- pygsti/layouts/termlayout.py +1 -1
- pygsti/modelmembers/instruments/instrument.py +3 -3
- pygsti/modelmembers/instruments/tpinstrument.py +2 -2
- pygsti/modelmembers/modelmember.py +0 -17
- pygsti/modelmembers/operations/__init__.py +3 -4
- pygsti/modelmembers/operations/affineshiftop.py +206 -0
- pygsti/modelmembers/operations/composederrorgen.py +1 -1
- pygsti/modelmembers/operations/composedop.py +1 -24
- pygsti/modelmembers/operations/denseop.py +5 -5
- pygsti/modelmembers/operations/eigpdenseop.py +2 -2
- pygsti/modelmembers/operations/embeddederrorgen.py +1 -1
- pygsti/modelmembers/operations/embeddedop.py +0 -1
- pygsti/modelmembers/operations/experrorgenop.py +5 -2
- pygsti/modelmembers/operations/fullarbitraryop.py +1 -0
- pygsti/modelmembers/operations/fullcptpop.py +2 -2
- pygsti/modelmembers/operations/fulltpop.py +28 -6
- pygsti/modelmembers/operations/fullunitaryop.py +5 -4
- pygsti/modelmembers/operations/lindbladcoefficients.py +93 -78
- pygsti/modelmembers/operations/lindbladerrorgen.py +268 -441
- pygsti/modelmembers/operations/linearop.py +7 -27
- pygsti/modelmembers/operations/opfactory.py +1 -1
- pygsti/modelmembers/operations/repeatedop.py +1 -24
- pygsti/modelmembers/operations/staticstdop.py +1 -1
- pygsti/modelmembers/povms/__init__.py +3 -3
- pygsti/modelmembers/povms/basepovm.py +7 -36
- pygsti/modelmembers/povms/complementeffect.py +4 -9
- pygsti/modelmembers/povms/composedeffect.py +0 -320
- pygsti/modelmembers/povms/computationaleffect.py +1 -1
- pygsti/modelmembers/povms/computationalpovm.py +3 -1
- pygsti/modelmembers/povms/effect.py +3 -5
- pygsti/modelmembers/povms/marginalizedpovm.py +3 -81
- pygsti/modelmembers/povms/tppovm.py +74 -2
- pygsti/modelmembers/states/__init__.py +2 -5
- pygsti/modelmembers/states/composedstate.py +0 -317
- pygsti/modelmembers/states/computationalstate.py +3 -3
- pygsti/modelmembers/states/cptpstate.py +4 -4
- pygsti/modelmembers/states/densestate.py +10 -8
- pygsti/modelmembers/states/fullpurestate.py +0 -24
- pygsti/modelmembers/states/purestate.py +1 -1
- pygsti/modelmembers/states/state.py +5 -6
- pygsti/modelmembers/states/tpstate.py +28 -10
- pygsti/modelmembers/term.py +3 -6
- pygsti/modelmembers/torchable.py +50 -0
- pygsti/modelpacks/_modelpack.py +1 -1
- pygsti/modelpacks/smq1Q_ZN.py +3 -1
- pygsti/modelpacks/smq2Q_XXYYII.py +2 -1
- pygsti/modelpacks/smq2Q_XY.py +3 -3
- pygsti/modelpacks/smq2Q_XYI.py +2 -2
- pygsti/modelpacks/smq2Q_XYICNOT.py +3 -3
- pygsti/modelpacks/smq2Q_XYICPHASE.py +3 -3
- pygsti/modelpacks/smq2Q_XYXX.py +1 -1
- pygsti/modelpacks/smq2Q_XYZICNOT.py +3 -3
- pygsti/modelpacks/smq2Q_XYZZ.py +1 -1
- pygsti/modelpacks/stdtarget.py +0 -121
- pygsti/models/cloudnoisemodel.py +1 -2
- pygsti/models/explicitcalc.py +3 -3
- pygsti/models/explicitmodel.py +3 -13
- pygsti/models/fogistore.py +5 -3
- pygsti/models/localnoisemodel.py +1 -2
- pygsti/models/memberdict.py +0 -12
- pygsti/models/model.py +801 -68
- pygsti/models/modelconstruction.py +4 -4
- pygsti/models/modelnoise.py +2 -2
- pygsti/models/modelparaminterposer.py +1 -1
- pygsti/models/oplessmodel.py +1 -1
- pygsti/models/qutrit.py +15 -14
- pygsti/objectivefns/objectivefns.py +75 -140
- pygsti/objectivefns/wildcardbudget.py +2 -7
- pygsti/optimize/__init__.py +1 -0
- pygsti/optimize/arraysinterface.py +28 -0
- pygsti/optimize/customcg.py +0 -12
- pygsti/optimize/customlm.py +129 -323
- pygsti/optimize/customsolve.py +2 -2
- pygsti/optimize/optimize.py +0 -84
- pygsti/optimize/simplerlm.py +841 -0
- pygsti/optimize/wildcardopt.py +19 -598
- pygsti/protocols/confidenceregionfactory.py +28 -14
- pygsti/protocols/estimate.py +31 -14
- pygsti/protocols/gst.py +238 -142
- pygsti/protocols/modeltest.py +19 -12
- pygsti/protocols/protocol.py +9 -37
- pygsti/protocols/rb.py +450 -79
- pygsti/protocols/treenode.py +8 -2
- pygsti/protocols/vb.py +108 -206
- pygsti/protocols/vbdataframe.py +1 -1
- pygsti/report/factory.py +0 -15
- pygsti/report/fogidiagram.py +1 -17
- pygsti/report/modelfunction.py +12 -3
- pygsti/report/mpl_colormaps.py +1 -1
- pygsti/report/plothelpers.py +11 -3
- pygsti/report/report.py +16 -0
- pygsti/report/reportables.py +41 -37
- pygsti/report/templates/offline/pygsti_dashboard.css +6 -0
- pygsti/report/templates/offline/pygsti_dashboard.js +12 -0
- pygsti/report/workspace.py +2 -14
- pygsti/report/workspaceplots.py +328 -505
- pygsti/tools/basistools.py +9 -36
- pygsti/tools/edesigntools.py +124 -96
- pygsti/tools/fastcalc.cp39-win_amd64.pyd +0 -0
- pygsti/tools/fastcalc.pyx +35 -81
- pygsti/tools/internalgates.py +151 -15
- pygsti/tools/jamiolkowski.py +5 -5
- pygsti/tools/lindbladtools.py +19 -11
- pygsti/tools/listtools.py +0 -114
- pygsti/tools/matrixmod2.py +1 -1
- pygsti/tools/matrixtools.py +173 -339
- pygsti/tools/nameddict.py +1 -1
- pygsti/tools/optools.py +154 -88
- pygsti/tools/pdftools.py +0 -25
- pygsti/tools/rbtheory.py +3 -320
- pygsti/tools/slicetools.py +64 -12
- pyGSTi-0.9.12.dist-info/METADATA +0 -157
- pygsti/algorithms/directx.py +0 -711
- pygsti/evotypes/qibo/__init__.py +0 -33
- pygsti/evotypes/qibo/effectreps.py +0 -78
- pygsti/evotypes/qibo/opreps.py +0 -376
- pygsti/evotypes/qibo/povmreps.py +0 -98
- pygsti/evotypes/qibo/statereps.py +0 -174
- pygsti/extras/rb/__init__.py +0 -13
- pygsti/extras/rb/benchmarker.py +0 -957
- pygsti/extras/rb/dataset.py +0 -378
- pygsti/extras/rb/io.py +0 -814
- pygsti/extras/rb/simulate.py +0 -1020
- pygsti/io/legacyio.py +0 -385
- pygsti/modelmembers/povms/denseeffect.py +0 -142
- {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/LICENSE +0 -0
- {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/top_level.txt +0 -0
@@ -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 :
|
29
|
-
A list
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
-
|
121
|
-
|
122
|
-
#
|
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
|
193
|
-
ret = ProtectedArray(ret)
|
194
|
-
|
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
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
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
|
+
|
pygsti/baseobjs/statespace.py
CHANGED
@@ -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.
|
pygsti/circuits/__init__.py
CHANGED
@@ -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
|