pyGSTi 0.9.12.1__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 (221) hide show
  1. pyGSTi-0.9.13.dist-info/METADATA +185 -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.cp38-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.cp38-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.cp38-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.cp38-win32.pyd +0 -0
  39. pygsti/evotypes/densitymx/effectreps.pyx +1 -1
  40. pygsti/evotypes/densitymx/opreps.cp38-win32.pyd +0 -0
  41. pygsti/evotypes/densitymx/opreps.pyx +2 -2
  42. pygsti/evotypes/densitymx/statereps.cp38-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.cp38-win32.pyd +0 -0
  49. pygsti/evotypes/stabilizer/effectreps.pyx +0 -4
  50. pygsti/evotypes/stabilizer/opreps.cp38-win32.pyd +0 -0
  51. pygsti/evotypes/stabilizer/opreps.pyx +0 -4
  52. pygsti/evotypes/stabilizer/statereps.cp38-win32.pyd +0 -0
  53. pygsti/evotypes/stabilizer/statereps.pyx +1 -5
  54. pygsti/evotypes/stabilizer/termreps.cp38-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.cp38-win32.pyd +0 -0
  60. pygsti/evotypes/statevec/effectreps.pyx +1 -1
  61. pygsti/evotypes/statevec/opreps.cp38-win32.pyd +0 -0
  62. pygsti/evotypes/statevec/opreps.pyx +2 -2
  63. pygsti/evotypes/statevec/statereps.cp38-win32.pyd +0 -0
  64. pygsti/evotypes/statevec/statereps.pyx +1 -1
  65. pygsti/evotypes/statevec/termreps.cp38-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.cp38-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.cp38-win32.pyd +0 -0
  84. pygsti/forwardsims/termforwardsim_calc_statevec.cp38-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.cp38-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
@@ -1,378 +0,0 @@
1
- """ Encapsulates RB results and dataset objects """
2
- #***************************************************************************************************
3
- # Copyright 2015, 2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
4
- # Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights
5
- # in this software.
6
- # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7
- # in compliance with the License. You may obtain a copy of the License at
8
- # http://www.apache.org/licenses/LICENSE-2.0 or in the LICENSE file in the root pyGSTi directory.
9
- #***************************************************************************************************
10
-
11
- import copy as _copy
12
-
13
- import numpy as _np
14
-
15
- #from . import analysis as _analysis # Doesn't exist!
16
- _analysis = None # TODO - fix or remove this dependency
17
-
18
-
19
- def create_summary_datasets(ds, spec, datatype='adjusted', verbosity=1):
20
- """
21
- todo
22
-
23
- """
24
- structure = spec.get_structure()
25
- circuits = spec.get_circuits()
26
- lengths = list(circuits.keys())
27
- lengths.sort()
28
-
29
- success_counts = {}
30
- total_counts = {}
31
- hamming_distance_counts = {}
32
-
33
- for qubits in structure:
34
-
35
- if datatype == 'raw':
36
- success_counts[qubits] = {}
37
- total_counts[qubits] = {}
38
- hamming_distance_counts[qubits] = None
39
-
40
- elif datatype == 'adjusted':
41
- success_counts[qubits] = None
42
- total_counts[qubits] = None
43
- hamming_distance_counts[qubits] = {}
44
-
45
- else:
46
- raise ValueError("Requested data type ` {} ` not understood!".format(datatype))
47
-
48
- if verbosity == 1:
49
- tab = ' '
50
- if verbosity > 1:
51
- tab = ' '
52
-
53
- for mit, (m, circuitlist) in enumerate(circuits.items()):
54
-
55
- if verbosity > 0:
56
- print(tab + "- Processing length {} of {}".format(mit + 1, len(circuits)))
57
-
58
- for qubits in structure:
59
- if datatype == 'raw':
60
- success_counts[qubits][m] = []
61
- total_counts[qubits][m] = []
62
- elif datatype == 'adjusted':
63
- hamming_distance_counts[qubits][m] = []
64
-
65
- for (circ, target) in circuitlist:
66
- dsrow = ds[circ]
67
- for qubits in structure:
68
- if datatype == 'raw':
69
- success_counts[qubits][m].append(_analysis.marginalized_success_counts(dsrow, circ, target, qubits))
70
- total_counts[qubits][m].append(dsrow.total)
71
- elif datatype == 'adjusted':
72
- hamming_distance_counts[qubits][m].append(
73
- _analysis.marginalized_hamming_distance_counts(dsrow, circ, target, qubits))
74
-
75
- summary_data = {}
76
- for qubits in structure:
77
- #print(success_counts[qubits])
78
- #print(total_counts[qubits])
79
- #print(hamming_distance_counts[qubits])
80
- summary_data[qubits] = RBSummaryDataset(len(qubits), success_counts=success_counts[qubits],
81
- total_counts=total_counts[qubits],
82
- hamming_distance_counts=hamming_distance_counts[qubits])
83
-
84
- return summary_data
85
-
86
-
87
- class RBSummaryDataset(object):
88
- """
89
- An object to summarize the results of RB experiments as relevant to implementing a standard RB analysis on the data.
90
- This dataset type only records the "RB length" of a circuit, how many times the circuit resulted in "success", and,
91
- optionally, some basic circuit information that can be helpful in understandingthe results. I.e., it doesn't
92
- store all the details about the circuits and the counts for each circuit (use a standard DataSet object to store
93
- the entire output of RB experiments).
94
- """
95
-
96
- def __init__(self, num_qubits, success_counts=None, total_counts=None, hamming_distance_counts=None,
97
- aux=None, finitecounts=True, descriptor=''):
98
- """
99
- # todo : update.
100
-
101
- Initialize an RB summary dataset.
102
-
103
- Parameters
104
- ----------
105
- num_qubits : int
106
- The number of qubits the dataset is for. This should be the number of qubits the RB experiments where
107
- "holistically" performed on. So, this dataset type is not suitable for, e.g., a *full* set of simultaneous
108
- RB data, which consists of parallel RB on different qubits. Data of that sort can be input into
109
- multiple RBSummaryDataset objects.
110
-
111
- lengths : list of ints
112
- A list of the "RB lengths" that the data is for. I.e., these are the "m" values in Pm = A + Bp^m.
113
- E.g., for direct RB this should be the number of circuit layers of native gates in the "core" circuit
114
- (i.e., not including the prep/measure stabilizer circuits). For Clifford RB this should be the number of
115
- Cliffords in the circuit (+ an arbitrary constant, traditionally -1, but -2 is more consistent with
116
- direct RB and is the pyGSTi convention for generating CRB circuits) *before* it is compiled into the
117
- native gates. This can always be the length value used to generate the circuit, if a pyGSTi RB
118
- circuit/experiment generation function was used to generate the circuit.
119
-
120
- This list should be the same length as the input results data (e.g., `success_counts` below). If
121
- `sortedinput` is False (the default), it is a list that has an entry for each circuit run (so values
122
- can appear multiple times in the list and in any order). If `sortedinput` is True is an ordered list
123
- containing each and every RB length once.
124
-
125
- success_counts : list of ints, or list of list of ints, optional
126
- Success counts, i.e., the number of times a circuit returns the "success" result. Normally this
127
- should be a list containing ints with `success_counts[i]` containing the success counts for a circuit
128
- with RB length `length[i]`. This is the case when `sortedinput` is False. But, if `sortedinput` is
129
- True, it is instead a list of lists of ints: the list at `success_counts[i]` contains the data for
130
- all circuits with RB length `lengths[i]` (in this case `lengths` is an ordered list containing each
131
- RB length once). `success_counts` can be None, and the data can instead be specified via
132
- `success_probabilities`. But, inputing the data as success counts is the preferred option for
133
- experimental data.
134
-
135
- total_counts : int, or list of ints, or list of list of ints, optional
136
- If not None, an int that specifies the total number of counts per circuit *or* a list that specifies
137
- the total counts for each element in success_counts (or success_probabilities). This is *not* optional
138
- if success_counts is provided, and should always be specified with experimental data.
139
-
140
- success_probabilities : list of floats, or list of list of floats, optional
141
- The same as `success_counts` except that this list specifies observed survival probabilities, rather
142
- than the number of success counts. Can only be specified if `success_counts` is None, and it is better
143
- to input experimental data as `success_counts` (but this option is useful for finite-sampling-free
144
- simulated data).
145
-
146
- circuit_depths : list of ints, or list of list of ints, optional
147
- Has same format has `success_counts` or `success_probabilities`. Contains circuit depths. This is
148
- additional auxillary information that it is often useful to have when analyzing data from any type
149
- of RB that includes any compilation (e.g., Clifford RB). But this is not essential.
150
-
151
- circuit_twoQgate_counts : list of ints, or list of list of ints, optional
152
- Has same format has `success_counts` or `success_probabilities`. Contains circuit 2-qubit gate counts.
153
- This is additional auxillary information that it is often useful for interpretting RB results.
154
-
155
- descriptor : str, optional
156
- A string that describes what the data is for.
157
-
158
- """
159
- if aux is None:
160
- aux = {}
161
- self.num_qubits = num_qubits
162
- self.finitecounts = finitecounts
163
- self.aux = _copy.deepcopy(aux)
164
- self.descriptor = descriptor
165
-
166
- assert(not (success_counts is not None and hamming_distance_counts is not None)), "Only one data " + \
167
- "type should be provided!"
168
-
169
- if success_counts is not None:
170
-
171
- self.datatype = 'success_counts'
172
- self.counts = _copy.deepcopy(success_counts)
173
- if self.finitecounts:
174
- assert(total_counts is not None), "The total counts per circuit is required!"
175
- self._total_counts = _copy.deepcopy(total_counts)
176
- else:
177
- self._total_counts = 1
178
-
179
- elif hamming_distance_counts is not None:
180
-
181
- self.datatype = 'hamming_distance_counts'
182
- self.counts = _copy.deepcopy(hamming_distance_counts)
183
-
184
- assert(total_counts is None), "The total counts per circuit should not be provided, " + \
185
- "as it is implicit in the Hamming distance data!"
186
-
187
- if self.finitecounts:
188
- # For Hamming distance data we just compute total counts on the fly.
189
- self._total_counts = None
190
- else:
191
- self._total_counts = 1
192
-
193
- else:
194
- raise ValueError("No data provided! `success_counts` or `hamming_distance_counts` must be not None!")
195
-
196
- lengths = list(self.counts.keys())
197
- lengths.sort()
198
- self.lengths = lengths
199
-
200
- # Generate "standard" and "adjusted" success probabilities
201
-
202
- self.SPs = []
203
- self.ASPs = []
204
- for l in self.lengths:
205
- SPs = [self.success_counts(l, i) / self.total_counts(l, i) for i in range(len(self.counts[l]))]
206
- self.SPs.append(SPs)
207
- self.ASPs.append(_np.mean(SPs))
208
-
209
- if self.datatype == 'hamming_distance_counts':
210
- self.adjusted_SPs = []
211
- self.adjusted_ASPs = []
212
- for l in self.lengths:
213
- adjSPs = [self.adjusted_success_probability(l, i) for i in range(len(self.counts[l]))]
214
- self.adjusted_SPs.append(adjSPs)
215
- self.adjusted_ASPs.append(_np.mean(adjSPs))
216
-
217
- else:
218
- self.adjusted_SPs = None
219
- self.adjusted_ASPs = None
220
-
221
- self.bootstraps = []
222
-
223
- return
224
-
225
- def adjusted_success_probability(self, length, index):
226
- """
227
- todo.
228
- """
229
- return _analysis.adjusted_success_probability(self.hamming_distance_distribution(length, index))
230
-
231
- def success_counts(self, length, index):
232
- """
233
- todo
234
-
235
- """
236
- if self.datatype == 'success_counts':
237
- return self.counts[length][index]
238
-
239
- else:
240
- return self.counts[length][index][0]
241
-
242
- def total_counts(self, length, index):
243
- """
244
- todo
245
-
246
- """
247
- if isinstance(self._total_counts, int):
248
- return self._total_counts
249
-
250
- elif self._total_counts is None:
251
- return _np.sum(self.counts[length][index])
252
-
253
- else:
254
- return self._total_counts[length][index]
255
-
256
- def hamming_distance_distribution(self, length, index):
257
- """
258
- todo
259
-
260
- """
261
- if self.datatype == 'hamming_distance_counts':
262
- return self.counts[length][index] / _np.sum(self.counts[length][index])
263
-
264
- else:
265
- raise ValueError("This is only possible for Hamming distance count data!")
266
-
267
- def success_probabilities(self, successtype='raw'):
268
- """
269
- todo.
270
-
271
- """
272
- if successtype == 'raw':
273
- return self.lengths, self.ASPs, self.SPs
274
-
275
- elif successtype == 'adjusted':
276
- return self.lengths, self.adjusted_ASPs, self.adjusted_SPs
277
-
278
- def add_bootstrapped_datasets(self, samples=1000):
279
- """
280
- Adds bootstrapped data. The bootstrap is over both the finite counts of each
281
- circuit and over the circuits at each length.
282
-
283
- Parameters
284
- ----------
285
- samples : int, optional
286
- The number of bootstrapped data to construct.
287
-
288
- Returns
289
- -------
290
- None
291
- """
292
- for i in range(len(self.bootstraps), samples):
293
-
294
- # A new set of bootstrapped success counts, or Hamming distance counts.
295
- if self.datatype == 'success_counts':
296
-
297
- success_counts = {}
298
- hamming_distance_counts = None
299
- total_counts = {}
300
-
301
- for j, l in enumerate(self.lengths):
302
-
303
- success_counts[l] = []
304
- if self.finitecounts:
305
- total_counts[l] = []
306
- else:
307
- total_counts = None
308
- numcircuits = len(self.SPs[j])
309
-
310
- for k in range(numcircuits):
311
-
312
- ind = _np.random.randint(numcircuits)
313
- sampledSP = self.SPs[j][ind]
314
- totalcounts = self.total_counts(l, ind)
315
- if self.finitecounts:
316
- success_counts[l].append(_np.random.binomial(totalcounts, sampledSP))
317
- total_counts[l].append(totalcounts)
318
- else:
319
- success_counts[l].append(sampledSP)
320
-
321
- else:
322
-
323
- success_counts = None
324
- hamming_distance_counts = {}
325
- total_counts = None
326
-
327
- for j, l in enumerate(self.lengths):
328
-
329
- hamming_distance_counts[l] = []
330
- numcircuits = len(self.SPs[j])
331
-
332
- for k in range(numcircuits):
333
-
334
- ind = _np.random.randint(numcircuits)
335
- sampledHDProbs = self.hamming_distance_distribution(l, ind)
336
-
337
- if self.finitecounts:
338
- totalcounts = self.total_counts(l, ind)
339
- hamming_distance_counts[l].append(list(_np.random.multinomial(totalcounts, sampledHDProbs)))
340
- else:
341
- hamming_distance_counts[l].append(sampledHDProbs)
342
-
343
- bootstrapped_dataset = RBSummaryDataset(self.num_qubits, success_counts, total_counts,
344
- hamming_distance_counts, finitecounts=self.finitecounts,
345
- descriptor='data created from a non-parametric bootstrap')
346
-
347
- self.bootstraps.append(bootstrapped_dataset)
348
-
349
- # todo : add this back in.
350
- # def create_smaller_dataset(self, numberofcircuits):
351
- # """
352
- # Creates a new dataset that has discarded the data from all but the first `numberofcircuits`
353
- # circuits at each length.
354
-
355
- # Parameters
356
- # ----------
357
- # numberofcircuits : int
358
- # The maximum number of circuits to keep at each length.
359
-
360
- # Returns
361
- # -------
362
- # RBSummaryDataset
363
- # A new dataset containing less data.
364
- # """
365
- # newRBSdataset = _copy.deepcopy(self)
366
- # for i in range(len(newRBSdataset.lengths)):
367
- # if newRBSdataset.success_counts is not None:
368
- # newRBSdataset.success_counts[i] = newRBSdataset.success_counts[i][:numberofcircuits]
369
- # if newRBSdataset.success_probabilities is not None:
370
- # newRBSdataset.success_probabilities[i] = newRBSdataset.success_probabilities[i][:numberofcircuits]
371
- # if newRBSdataset.total_counts is not None:
372
- # newRBSdataset.total_counts[i] = newRBSdataset.total_counts[i][:numberofcircuits]
373
- # if newRBSdataset.circuit_depths is not None:
374
- # newRBSdataset.circuit_depths[i] = newRBSdataset.circuit_depths[i][:numberofcircuits]
375
- # if newRBSdataset.circuit_twoQgate_counts is not None:
376
- # newRBSdataset.circuit_twoQgate_counts[i] = newRBSdataset.circuit_twoQgate_counts[i][:numberofcircuits]
377
-
378
- # return newRBSdataset