Skip to content

Commit 6049cbb

Browse files
author
Erik Nielsen
committed
MANUAL Merge branch 'develop' into beta - so we can release 0.9.7.2
Some tests on TravisCI are still failing, but tests pass locally except for known SVD errors during gauge opt. We're in the process of getting the TravisCI builds & tests working again.
2 parents 4b10e58 + 0d185fc commit 6049cbb

26 files changed

+237618
-211
lines changed

packages/pygsti/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# in the file "license.txt" in the top-level pyGSTi directory
55
#*****************************************************************
66
""" PyGSTi version number """
7-
__version__ = "0.9.7.1"
7+
__version__ = "0.9.7.2"

packages/pygsti/baseobjs/label.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,8 @@ def __new__(cls,name,tupOfTups,stateSpaceLabels,reps=1): # timestamp??
639639
The item data - a tuple of (string, state-space-labels) tuples
640640
which labels a parallel layer/level of a circuit.
641641
"""
642-
assert(isinstance(reps, _numbers.Integral) and isstr(name))
642+
#if name is None: name = '' # backward compatibility (temporary - TODO REMOVE)
643+
assert(isinstance(reps, _numbers.Integral) and isstr(name)), "Invalid name or reps: %s %s" % (str(name),str(reps))
643644
tupOfLabels = tuple((Label(tup) for tup in tupOfTups)) # Note: tup can also be a Label obj
644645
return tuple.__new__(cls, (name,stateSpaceLabels,reps) + tupOfLabels) # creates a CircuitLabel object using tuple's __new__
645646

packages/pygsti/extras/drift/core.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from ... import objects as _obj
1616
from ...tools import hypothesis as _hyp
17+
from ...tools import compattools as _compat
1718

1819
import numpy as _np
1920
import warnings as _warnings
@@ -68,7 +69,7 @@ def do_drift_characterization(ds, significance=0.05, marginalize='auto', transfo
6869
spectrafrequencies='auto', testFreqInds=None,
6970
groupoutcomes=None, enforceConstNumTimes='auto',
7071
whichTests=(('avg','avg','avg'), ('per','avg','avg'), ('per','per','avg')),
71-
betweenClassCorrection=True, inClassCorrection=('FWER','FWER','FDR','FDR'),
72+
betweenClassCorrection=True, inClassCorrection=('FWER','FWER','FWER','FWER'),
7273
modelSelectionMethod=(('per','per','avg'),'detection'), estimator='FF-UAR',
7374
verbosity=1, name=None):
7475
"""
@@ -256,7 +257,7 @@ def format_data(ds, marginalize='auto', groupoutcomes=None, enforceConstNumTimes
256257
# We do this, because this gets recorded in the results as whether we *have* enforced this.
257258
enforceConstNumTimes = False
258259

259-
if isinstance(marginalize,str):
260+
if _compat.isstr(marginalize):
260261
assert(marginalize == 'auto')
261262
if len(list(ds.get_outcome_labels())) > 4:
262263
marginalize = True
@@ -816,4 +817,4 @@ def estimate_probability_trajectories(results, modelSelector=(('per','per','avg'
816817
#params, recon, uncert, aux = _est.estimate_probability_trace(timeseries, timestamps, results.transform, estimator,
817818
# hyperparameters, modes=modes, estimatorSettings)
818819

819-
return None
820+
return None

packages/pygsti/extras/idletomography/idtcore.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,6 @@ def do_idle_tomography(nQubits, dataset, maxLengths, pauliBasisDicts, maxweight=
10921092
else:
10931093
line_labels = (0,)
10941094
GiStr = _objs.Circuit( idle_string, line_labels=line_labels )
1095-
print("Dataset has ",dataset)
10961095
else:
10971096
GiStr = _objs.Circuit( idle_string, num_lines=nQubits )
10981097

packages/pygsti/extras/rb/simulate.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def oneshot_circuit_simulator_for_tensored_independent_pauli_errors(circuit, psp
142142

143143
for l in range(depth):
144144

145-
layer = circuit.get_layer_with_idles(l,idleGateName=idle1Q_placeholder)
145+
layer = circuit.get_layer_with_idles(l, idleGateName=idle1Q_placeholder)
146146
s, p = _symp.symplectic_rep_of_clifford_layer(layer,n,Qlabels=circuit.line_labels,srep_dict=srep)
147147
# Apply the perfect layer to the current state.
148148
sout, pout = _symp.apply_clifford_to_stabilizer_state(s, p, sout, pout)
@@ -183,7 +183,7 @@ def oneshot_circuit_simulator_for_tensored_independent_pauli_errors(circuit, psp
183183
return outputasstring
184184

185185
def rb_with_pauli_errors(pspec, errormodel, lengths, k, counts, subsetQs=None, filename=None, rbtype='DRB',
186-
rbspec =[], returndata=True, appenddata=False, verbosity=0):
186+
rbspec =[], returndata=True, appenddata=False, verbosity=0, idle1Q_placeholder='I'):
187187
"""
188188
Simulates RB with Pauli errors. Can be used to simulated Clifford RB, direct RB and mirror RB. This
189189
function:
@@ -293,7 +293,7 @@ def rb_with_pauli_errors(pspec, errormodel, lengths, k, counts, subsetQs=None, f
293293
# print(" - Simulating circuit...",end='')
294294

295295
outcome = circuit_simulator_for_tensored_independent_pauli_errors(
296-
c, pspec, errormodel, counts, alloutcomes=False,idle1Q_placeholder='I')
296+
c, pspec, errormodel, counts, alloutcomes=False, idle1Q_placeholder=idle1Q_placeholder)
297297
#EGN: Hardcoded 'I' here. Could make this into an arg, but there's really
298298
# no need for the user to modify this unless they use 'I' as a gate label.
299299
if verbosity > 0: print(lind+1,end=',')
@@ -498,7 +498,9 @@ def error_row(er): return _np.array([1-er,0.,0.,er])
498498

499499
return errormodel
500500

501-
501+
#
502+
# TODO : DOES THIS NEED AND IDLE PLACEHOLDER?
503+
#
502504
def create_local_pauli_error_model(pspec, oneQgate_errorrate_dict, twoQgate_errorrate_dict,
503505
measurement_errorrate_dict={}, ptype='uniform'):
504506
"""

packages/pygsti/objects/dataset.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,18 @@ def load(self, fileOrFilename):
17711771
else:
17721772
f = fileOrFilename
17731773

1774-
state_dict = _pickle.load(f)
1774+
try:
1775+
state_dict = _pickle.load(f)
1776+
except AttributeError:
1777+
# HACK TO ALLOW UUIDs saved on python3.7 work with earlier python versions that don't have uuid.SafeUUID
1778+
# HACK - maybe move this to leagacyio to deal with Python 3 versions < 3.7 not having SafeUUID?
1779+
class dummy_SafeUUID(object):
1780+
def __new__(self,*args):
1781+
return _uuid.UUID.__new__(uuid.UUID,*args)
1782+
_sys.modules['uuid'].SafeUUID = dummy_SafeUUID
1783+
state_dict = _pickle.load(f)
1784+
del _sys.modules['uuid'].SafeUUID
1785+
17751786

17761787
if "gsIndexKeys" in state_dict:
17771788
_warnings.warn("Loading a deprecated-format DataSet. Please re-save asap.")

packages/pygsti/report/plotly_plot_ex.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#*****************************************************************
88

99
import os as _os
10+
from plotly import __version__ as _plotly_version
1011
from plotly import tools as _plotlytools
1112
from plotly.offline.offline import _plot_html
1213
#from plotly.offline.offline import get_plotlyjs
@@ -99,12 +100,17 @@ def plot_ex(figure_or_data, show_link=True, link_text='Export to plot.ly',
99100
config['showLink'] = show_link
100101
config['linkText'] = link_text
101102

103+
#Add version-dependent kwargs to _plot_html call below
104+
kwargs = {}
105+
if tuple(map(int,_plotly_version.split('.'))) >= (3,7,0): # then auto_play arg exists
106+
kwargs['auto_play'] = False
107+
102108
#Note: removing width and height from layout above causes default values to
103-
# be used (the '100%'s hardcoded below) which subsequently trigger adding a resize script.
109+
# be used (the '100%'s hardcoded below) which subsequently trigger adding a resize script.
104110
plot_html, plotdivid, _, _ = _plot_html(
105111
fig, config, validate, '100%', '100%',
106-
global_requirejs=False) #no need for global_requirejs here
107-
#since we now extract js and remake full script.
112+
global_requirejs=False, #no need for global_requirejs here
113+
**kwargs) #since we now extract js and remake full script.
108114

109115
if orig_width: fig['layout']['width'] = orig_width
110116
if orig_height: fig['layout']['height'] = orig_height

packages/pygsti/report/workspaceplots.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,14 +1623,14 @@ def _create(self, plottypes, gss, dataset, model,
16231623
linlog_color = "yellow"
16241624
ytitle="chi<sup>2</sup>"
16251625
mx_fn = _mx_fn_directchi2 # use a *global* function so cache can tell it's the same
1626-
extra_arg = (dataset, directGSTmodels, minProbClipForWeighting)
1626+
extra_arg = (dataset, directGSTmodels, minProbClipForWeighting, gss)
16271627

16281628
elif ptyp == "directlogl":
16291629
colormapType = "linlog"
16301630
linlog_color = "yellow"
16311631
ytitle="Direct 2 log(L ratio)"
16321632
mx_fn = _mx_fn_directlogl # use a *global* function so cache can tell it's the same
1633-
extra_arg = (dataset, directGSTmodels, minProbClipForWeighting)
1633+
extra_arg = (dataset, directGSTmodels, minProbClipForWeighting, gss)
16341634

16351635
elif ptyp == "dscmp":
16361636
assert(dscomparator is not None), \
@@ -1818,13 +1818,13 @@ def _mx_fn_errorrate(plaq,x,y,directGSTmodels): #error rate as 1x1 matrix which
18181818
return _np.array( [[ _ph.small_eigval_err_rate(plaq.base, directGSTmodels) ]] )
18191819

18201820
def _mx_fn_directchi2(plaq,x,y,extra):
1821-
dataset, directGSTmodels, minProbClipForWeighting = extra
1821+
dataset, directGSTmodels, minProbClipForWeighting, gss = extra
18221822
return _ph.direct_chi2_matrix(
18231823
plaq, gss, dataset, directGSTmodels.get(plaq.base,None),
18241824
minProbClipForWeighting)
18251825

18261826
def _mx_fn_directlogl(plaq,x,y,extra):
1827-
dataset, directGSTmodels, minProbClipForWeighting = extra
1827+
dataset, directGSTmodels, minProbClipForWeighting, gss = extra
18281828
return _ph.direct_logl_matrix(
18291829
plaq, gss, dataset, directGSTmodels.get(plaq.base,None),
18301830
minProbClipForWeighting)

scripts/upgrade2v0.9.7.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ def main(argv):
442442
"gateset" : "model",
443443
"GateMap" : "MapOperator",
444444
"GateRep" : "OpRep",
445+
"pyquil.gates" : "pyquil.gates",
445446
".gates" : ".operations",
446447
"dgate" : "doperation",
447448
"hgate" : "hoperation",

test/test_packages/algorithms/testGaugeOpt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def test_gaugeopt_and_contract(self):
9292
mdl_lgst_tp = self.runSilent(pygsti.gaugeopt_to_target, mdl_lgst, None,
9393
spam_penalty_factor=1.0, verbosity=10, checkJac=True)
9494

95-
mdl_lgst.basis = Basis("gm",2) #so CPTP optimizations can work on mdl_lgst
95+
mdl_lgst.basis = Basis.cast("gm",2) #so CPTP optimizations can work on mdl_lgst
9696
mdl_lgst_cptp = self.runSilent(pygsti.gaugeopt_to_target, mdl_lgst, None,
9797
cptp_penalty_factor=1.0, spam_penalty_factor=1.0, verbosity=10, checkJac=True)
9898

0 commit comments

Comments
 (0)