pyGSTi 0.9.12__cp38-cp38-win_amd64.whl → 0.9.13__cp38-cp38-win_amd64.whl
Sign up to get free protection for your applications and to get access to all the features.
- pyGSTi-0.9.13.dist-info/METADATA +185 -0
- {pyGSTi-0.9.12.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.cp38-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.cp38-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.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/chp/opreps.py +0 -61
- pygsti/evotypes/chp/statereps.py +0 -32
- pygsti/evotypes/densitymx/effectcreps.cpp +9 -10
- pygsti/evotypes/densitymx/effectreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/densitymx/effectreps.pyx +1 -1
- pygsti/evotypes/densitymx/opreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/densitymx/opreps.pyx +2 -2
- pygsti/evotypes/densitymx/statereps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/densitymx/statereps.pyx +1 -1
- pygsti/evotypes/densitymx_slow/effectreps.py +7 -23
- pygsti/evotypes/densitymx_slow/opreps.py +16 -23
- pygsti/evotypes/densitymx_slow/statereps.py +10 -3
- pygsti/evotypes/evotype.py +39 -2
- pygsti/evotypes/stabilizer/effectreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/effectreps.pyx +0 -4
- pygsti/evotypes/stabilizer/opreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/opreps.pyx +0 -4
- pygsti/evotypes/stabilizer/statereps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/statereps.pyx +1 -5
- pygsti/evotypes/stabilizer/termreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/termreps.pyx +0 -7
- pygsti/evotypes/stabilizer_slow/effectreps.py +0 -22
- pygsti/evotypes/stabilizer_slow/opreps.py +0 -4
- pygsti/evotypes/stabilizer_slow/statereps.py +0 -4
- pygsti/evotypes/statevec/effectreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/effectreps.pyx +1 -1
- pygsti/evotypes/statevec/opreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/opreps.pyx +2 -2
- pygsti/evotypes/statevec/statereps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/statereps.pyx +1 -1
- pygsti/evotypes/statevec/termreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/termreps.pyx +0 -7
- pygsti/evotypes/statevec_slow/effectreps.py +0 -3
- pygsti/evotypes/statevec_slow/opreps.py +0 -5
- pygsti/extras/__init__.py +0 -1
- pygsti/extras/drift/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.cp38-win_amd64.pyd +0 -0
- pygsti/forwardsims/mapforwardsim_calc_densitymx.pyx +65 -66
- pygsti/forwardsims/mapforwardsim_calc_generic.py +91 -13
- pygsti/forwardsims/matrixforwardsim.py +72 -17
- pygsti/forwardsims/termforwardsim.py +9 -111
- pygsti/forwardsims/termforwardsim_calc_stabilizer.cp38-win_amd64.pyd +0 -0
- pygsti/forwardsims/termforwardsim_calc_statevec.cp38-win_amd64.pyd +0 -0
- pygsti/forwardsims/termforwardsim_calc_statevec.pyx +0 -651
- pygsti/forwardsims/torchfwdsim.py +265 -0
- pygsti/forwardsims/weakforwardsim.py +2 -2
- pygsti/io/__init__.py +1 -2
- pygsti/io/mongodb.py +0 -2
- pygsti/io/stdinput.py +6 -22
- pygsti/layouts/copalayout.py +10 -12
- pygsti/layouts/distlayout.py +0 -40
- pygsti/layouts/maplayout.py +103 -25
- pygsti/layouts/matrixlayout.py +99 -60
- pygsti/layouts/prefixtable.py +1534 -52
- pygsti/layouts/termlayout.py +1 -1
- pygsti/modelmembers/instruments/instrument.py +3 -3
- pygsti/modelmembers/instruments/tpinstrument.py +2 -2
- pygsti/modelmembers/modelmember.py +0 -17
- pygsti/modelmembers/operations/__init__.py +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.cp38-win_amd64.pyd +0 -0
- pygsti/tools/fastcalc.pyx +35 -81
- pygsti/tools/internalgates.py +151 -15
- pygsti/tools/jamiolkowski.py +5 -5
- pygsti/tools/lindbladtools.py +19 -11
- pygsti/tools/listtools.py +0 -114
- pygsti/tools/matrixmod2.py +1 -1
- pygsti/tools/matrixtools.py +173 -339
- pygsti/tools/nameddict.py +1 -1
- pygsti/tools/optools.py +154 -88
- pygsti/tools/pdftools.py +0 -25
- pygsti/tools/rbtheory.py +3 -320
- pygsti/tools/slicetools.py +64 -12
- pyGSTi-0.9.12.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
pygsti/extras/rb/dataset.py
DELETED
@@ -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
|