def test_add_estimate_warns_on_overwrite(self): with self.assertWarns(Warning): self.res.add_estimate( std.target_model(), std.target_model(), [self.model] * len(self.maxLengthList), parameters={'objective': 'logl'}, estimate_key="default") # re-init existing estimate
def test_circuitsim_stabilizer_1Qcheck(self): from pygsti.modelpacks.legacy import std1Q_XYI as stdChk maxLengths = [1, 2, 4] listOfExperiments = pygsti.construction.make_lsgst_experiment_list( stdChk.target_model(), stdChk.prepStrs, stdChk.effectStrs, stdChk.germs, maxLengths) #listOfExperiments = pygsti.construction.circuit_list([ ('Gcnot','Gxi') ]) #listOfExperiments = pygsti.construction.circuit_list([ ('Gxi','Gcphase','Gxi','Gix') ]) mdl_normal = stdChk.target_model() mdl_clifford = stdChk.target_model() #print(mdl_clifford['Gcnot']) self.assertTrue(stdChk.target_model()._evotype == "densitymx") mdl_clifford.set_all_parameterizations( 'static unitary') # reduces dim... self.assertTrue(mdl_clifford._evotype == "statevec") mdl_clifford.set_all_parameterizations('clifford') self.assertTrue(mdl_clifford._evotype == "stabilizer") for opstr in listOfExperiments: #print(str(opstr)) p_normal = mdl_normal.probs(opstr) p_clifford = mdl_clifford.probs(opstr) #p_clifford = bprobs[opstr] for outcm in p_normal.keys(): if abs(p_normal[outcm] - p_clifford[outcm]) > 1e-8: print(str(opstr), " ERR: \n", p_normal, "\n", p_clifford) self.assertTrue(False) print("Done checking %d sequences!" % len(listOfExperiments))
def test_add_estimate(self): self.res.add_estimate(estimate.Estimate.create_gst_estimate( self.res, std.target_model(), std.target_model(), [self.model] * len(self.maxLengthList), parameters={'objective': 'logl'}), estimate_key="default")
def test_general_decomp(self): gs1 = std.target_model().depolarize(op_noise=0.1, spam_noise=0.05) gs2 = std.target_model() gs1.operations['Gx'] = np.array( [[-1, 0, 0, 0], [0, -1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]], 'd') # -1 eigenvalues => use approx log. rptbl.general_decomposition(gs1, gs2)
def test_stdpracticeGST(self): ds = pygsti.objects.DataSet(fileToLoadFrom=compare_files + "/drivers.dataset") mdl_guess = std.target_model().depolarize(op_noise=0.01, spam_noise=0.01) #lower bad-fit threshold to zero to trigger bad-fit additional processing maxLens = self.maxLens result = self.runSilent(pygsti.do_stdpractice_gst, ds, std.target_model(), std.fiducials, std.fiducials, std.germs, maxLens, modes="TP,CPTP,Test,Target", modelsToTest={"Test": mdl_guess}, comm=None, memLimit=None, verbosity=5) pygsti.report.create_standard_report(result, temp_files + "/full_report_stdpractice", "Std Practice Test Report", verbosity=2)
def create_fake_dataset(comm): fidPairList = None maxLengths = [1,2,4,8,16] nSamples = 1000 #specs = pygsti.construction.build_spam_specs( # std.fiducials, prep_labels=std.target_model().get_prep_labels(), # effect_labels=std.target_model().get_effect_labels()) #rhoStrs, EStrs = pygsti.construction.get_spam_strs(specs) rhoStrs = EStrs = std.fiducials lgstStrings = pygsti.construction.list_lgst_circuits( rhoStrs, EStrs, list(std.target_model().operations.keys())) lsgstStrings = pygsti.construction.make_lsgst_lists( list(std.target_model().operations.keys()), rhoStrs, EStrs, std.germs, maxLengths, fidPairList ) lsgstStringsToUse = lsgstStrings allRequiredStrs = pygsti.remove_duplicates(lgstStrings + lsgstStrings[-1]) if comm is None or comm.Get_rank() == 0: mdl_dataGen = std.target_model().depolarize(op_noise=0.1) dsFake = pygsti.construction.generate_fake_data( mdl_dataGen, allRequiredStrs, nSamples, sampleError="multinomial", seed=1234) dsFake = comm.bcast(dsFake, root=0) else: dsFake = comm.bcast(None, root=0) #for mdl in dsFake: # if abs(dsFake[mdl]['0']-dsFake_cmp[mdl]['0']) > 0.5: # print("DS DIFF: ",mdl, dsFake[mdl]['0'], "vs", dsFake_cmp[mdl]['0'] ) return dsFake, lsgstStrings
def test_add_estimate(self): # add estimates self.res.add_estimate(std.target_model(), std.target_model(), [self.model] * len(self.maxLengthList), parameters={'objective': 'logl'}, estimate_key="default")
def test_pickle_ConfidenceRegion(self): edesign = proto.CircuitListsDesign([pygsti.circuits.CircuitList(circuit_struct) for circuit_struct in self.gss]) data = proto.ProtocolData(edesign, self.ds) res = proto.ModelEstimateResults(data, proto.StandardGST(modes="TP")) res.add_estimate( proto.estimate.Estimate.create_gst_estimate( res, stdxyi.target_model(), stdxyi.target_model(), [self.model]*len(self.maxLengthList), parameters={'objective': 'logl'}), estimate_key="default" ) est = res.estimates['default'] est.add_confidence_region_factory('final iteration estimate', 'final') self.assertTrue( est.has_confidence_region_factory('final iteration estimate', 'final')) cfctry = est.create_confidence_region_factory('final iteration estimate', 'final') cfctry.compute_hessian() self.assertTrue( cfctry.has_hessian ) cfctry.project_hessian('std') ci_std = cfctry.view( 95.0, 'normal', 'std') s = pickle.dumps(cfctry) cifctry2 = pickle.loads(s) s = pickle.dumps(ci_std) ci_std2 = pickle.loads(s)
def test_add_model_test(self): # add estimate from model test mdl_guess = std.target_model().depolarize(op_noise=0.07, spam_noise=0.03) self.res.add_model_test(std.target_model(), mdl_guess, estimate_key='Test', gauge_opt_keys="auto")
def setUp(self): super(ResultsEstimateTester, self).setUp() self.res.add_estimate(std.target_model(), std.target_model(), [self.model] * len(self.maxLengthList), parameters={'objective': 'logl'}, estimate_key="default") self.est = self.res.estimates['default']
def test_longSequenceGST_randomReduction(self): ds = pygsti.objects.DataSet(fileToLoadFrom=compare_files + "/drivers.dataset") ts = "whole germ powers" maxLens = self.maxLens #Without fixed initial fiducial pairs fidPairs = None reducedLists = pygsti.construction.make_lsgst_structs( std.target_model().operations.keys(), std.fiducials, std.fiducials, std.germs, maxLens, fidPairs, ts, keepFraction=0.5, keepSeed=1234) result = self.runSilent(pygsti.do_long_sequence_gst_base, ds, std.target_model(), reducedLists, advancedOptions={'truncScheme': ts}) #create a report... pygsti.report.create_standard_report(result, temp_files + "/full_report_RFPR", "RFPR report", verbosity=2) #With fixed initial fiducial pairs fidPairs = pygsti.alg.find_sufficient_fiducial_pairs( std.target_model(), std.fiducials, std.fiducials, std.germs, verbosity=0) reducedLists = pygsti.construction.make_lsgst_structs( std.target_model().operations.keys(), std.fiducials, std.fiducials, std.germs, maxLens, fidPairs, ts, keepFraction=0.5, keepSeed=1234) result2 = self.runSilent(pygsti.do_long_sequence_gst_base, ds, std.target_model(), reducedLists, advancedOptions={'truncScheme': ts}) #create a report... pygsti.report.create_standard_report(result2, temp_files + "/full_report_RFPR2.html", verbosity=2)
def test_MPI_gaugeopt(comm): #Gauge Opt to Target mdl_other = std.target_model().depolarize(op_noise=0.01, spam_noise=0.01) mdl_other['Gx'].rotate( (0,0,0.01) ) mdl_other['Gy'].rotate( (0,0,0.01) ) mdl_gopt = pygsti.gaugeopt_to_target(mdl_other, std.target_model(), verbosity=10, comm=comm) #use a method that isn't parallelized with non-None comm (warning is given) mdl_gopt_slow = pygsti.gaugeopt_to_target(mdl_other, std.target_model(), verbosity=10, method="BFGS", comm=comm)
def test_closest_unitary(self): gs1 = std.target_model().depolarize(op_noise=0.1, spam_noise=0.05) gs2 = std.target_model() rptbl.closest_unitary_fidelity(gs1.operations['Gx'], gs2.operations['Gx'], "pp") # op2 is unitary rptbl.closest_unitary_fidelity(gs2.operations['Gx'], gs1.operations['Gx'], "pp") # op1 is unitary
def setUp(self): super(PopulatedResultsTester, self).setUp() self.res.init_dataset(self.ds) self.res.init_circuits(self.gss) self.res.add_estimate(std.target_model(), std.target_model(), [self.model] * len(self.maxLengthList), parameters={'objective': 'logl'}, estimate_key="default")
def test_parameter_counting(self): #XY Model: SPAM=True n = stdxy.target_model().num_params self.assertEqual(n,44) # 2*16 + 3*4 = 44 n = stdxy.target_model().num_nongauge_params self.assertEqual(n,28) # full 16 gauge params #XY Model: SPAM=False tst = stdxy.target_model() del tst.preps['rho0'] del tst.povms['Mdefault'] n = tst.num_params self.assertEqual(n,32) # 2*16 = 32 n = tst.num_nongauge_params self.assertEqual(n,18) # gates are all unital & TP => only 14 gauge params (2 casimirs) #XYI Model: SPAM=True n = stdxyi.target_model().num_params self.assertEqual(n,60) # 3*16 + 3*4 = 60 n = stdxyi.target_model().num_nongauge_params self.assertEqual(n,44) # full 16 gauge params: SPAM gate + 3 others #XYI Model: SPAM=False tst = stdxyi.target_model() del tst.preps['rho0'] del tst.povms['Mdefault'] n = tst.num_params self.assertEqual(n,48) # 3*16 = 48 n = tst.num_nongauge_params self.assertEqual(n,34) # gates are all unital & TP => only 14 gauge params (2 casimirs) #XYI Model: SP0=False tst = stdxyi.target_model() tst.preps['rho0'] = pygsti.modelmembers.states.TPState(tst.preps['rho0']) n = tst.num_params self.assertEqual(n,59) # 3*16 + 2*4 + 3 = 59 n = tst.num_nongauge_params self.assertEqual(n,44) # 15 gauge params (minus one b/c can't change rho?) #XYI Model: G0=SP0=False tst.operations['Gi'] = pygsti.modelmembers.operations.FullTPOp(tst.operations['Gi']) tst.operations['Gx'] = pygsti.modelmembers.operations.FullTPOp(tst.operations['Gx']) tst.operations['Gy'] = pygsti.modelmembers.operations.FullTPOp(tst.operations['Gy']) n = tst.num_params self.assertEqual(n,47) # 3*12 + 2*4 + 3 = 47 n = tst.num_nongauge_params self.assertEqual(n,35) # full 12 gauge params of single 4x3 gate
def test_reports_logL_TP_noCIs(self): #Also test adding a model-test estimate to this report mdl_guess = std.target_model().depolarize(op_noise=0.07,spam_noise=0.03) results = self.results_logL.copy() results.add_model_test(std.target_model(), mdl_guess, estimate_key='Test', gauge_opt_keys="auto") #Note: this report will have (un-combined) Robust estimates too pygsti.report.create_standard_report(results,temp_files + "/general_reportC", "Report C", confidenceLevel=None, verbosity=3, auto_open=False, advancedOptions={'combine_robust': False} )
def setUpClass(cls): #Let's make our underlying model have a little bit of random unitary noise. cls.mdl_exp_0 = std1Q_XYI.target_model().randomize_with_unitary(.01, seed=0) cls.mdl_exp_1 = std1Q_XYI.target_model().randomize_with_unitary(.01, seed=1234) germs = std1Q_XYI.germs fiducials = std1Q_XYI.fiducials max_lengths = [1, 2, 4, 8] gate_sequences = pc.make_lsgst_experiment_list(std1Q_XYI.gates, fiducials, fiducials, germs, max_lengths) #Generate the data for the two datasets, using the same model, with 100 repetitions of each sequence. N = 100 cls.DS_0 = pc.generate_fake_data(cls.mdl_exp_0, gate_sequences, N, 'binomial', seed=10) cls.DS_1 = pc.generate_fake_data(cls.mdl_exp_1, gate_sequences, N, 'binomial', seed=20)
def test_memlimit(self): with self.assertRaises(MemoryError): # A very low memlimit pygsti.alg.find_sufficient_fiducial_pairs(std.target_model(), std.fiducials, std.fiducials, std.germs, test_pair_list=[(0,0),(0,1),(1,0)], verbosity=0, mem_limit=100) # 100 bytes! # A low memlimit pygsti.alg.find_sufficient_fiducial_pairs(std.target_model(), std.fiducials, std.fiducials, std.germs, test_pair_list=[(0,0),(0,1),(1,0)], verbosity=0, mem_limit=40 * 1024**2) # 10MB # A higher limit pygsti.alg.find_sufficient_fiducial_pairs(std.target_model(), std.fiducials, std.fiducials, std.germs, test_pair_list=[(0,0),(0,1),(1,0)], verbosity=0, mem_limit=80 * 1024**2) # 80MB
def setUp(self): super(RPEToolsFuncBase, self).setUp() self.target = stdXY.target_model() self.target.operations['Gi'] = std.target_model().operations[ 'Gi'] # need a Gi gate... self.stringListD = rpc.create_rpe_angle_circuits_dict(2, self.config) self.mdl_depolXZ = self.target.depolarize(op_noise=0.1, spam_noise=0.1, seed=_SEED) self.ds = pdata.simulate_data(self.mdl_depolXZ, self.stringListD['totalStrList'], num_samples=1000, sample_error='binomial', seed=_SEED)
def test_intelligentFiducialPairReduction(self): fidPairs = self.runSilent( pygsti.alg.find_sufficient_fiducial_pairs_per_germ, std.target_model(), std.fiducials, std.fiducials, std.germs, pre_povm_tuples="first", search_mode="sequential", constrain_to_tp=True, n_random=100, seed=None, verbosity=3, mem_limit=None) cmpFilenm = compare_files + "/IFPR_fidPairs_dict.pkl" # Run to SAVE reference fidPairs dictionary if regenerate_references(): with open(cmpFilenm,"wb") as pklfile: pickle.dump(fidPairs, pklfile) with open(cmpFilenm,"rb") as pklfile: fidPairs_cmp = pickle.load(pklfile) #On other machines (eg TravisCI) these aren't equal, due to randomness, so don't test #self.assertEqual(fidPairs, fidPairs_cmp) #test out some additional code paths: mem limit, random mode, & no good pair list fidPairs2 = self.runSilent( pygsti.alg.find_sufficient_fiducial_pairs_per_germ, std.target_model(), std.fiducials, std.fiducials, std.germs, pre_povm_tuples="first", search_mode="random", constrain_to_tp=True, n_random=3, seed=None, verbosity=3, mem_limit=1024*30) fidPairs3 = self.runSilent( #larger n_random pygsti.alg.find_sufficient_fiducial_pairs_per_germ, std.target_model(), std.fiducials, std.fiducials, std.germs, pre_povm_tuples="first", search_mode="random", constrain_to_tp=True, n_random=100, seed=None, verbosity=3, mem_limit=1024*30) fidPairs3b = self.runSilent( #huge n_random (should cap to all pairs) pygsti.alg.find_sufficient_fiducial_pairs_per_germ, std.target_model(), std.fiducials, std.fiducials, std.germs, pre_povm_tuples="first", search_mode="random", constrain_to_tp=True, n_random=1000000, seed=None, verbosity=3, mem_limit=1024*30)
def test_stdgst_map(self): # Using map-based calculation target_model = std.target_model() target_model.set_all_parameterizations("CPTP") target_model.set_simtype('map') results = pygsti.do_long_sequence_gst(self.ds, target_model, std.prepStrs, std.effectStrs, std.germs, self.maxLengths, verbosity=4) print("MISFIT nSigma = ", results.estimates['default'].misfit_sigma()) self.assertAlmostEqual(results.estimates['default'].misfit_sigma(), 1.0, delta=2.0) mdl_compare = pygsti.io.json.load( open(compare_files + "/test1Qcalc_std_exact.model")) gsEstimate = results.estimates['default'].models['go0'].copy() gsEstimate.set_all_parameterizations("full") gsEstimate = pygsti.algorithms.gaugeopt_to_target( gsEstimate, mdl_compare) self.assertAlmostEqual(gsEstimate.frobeniusdist(mdl_compare), 0, places=0)
def test_time_dependent_gst_staticdata(self): #run GST in a time-dependent mode: prep_fiducials, meas_fiducials = std1Q_XYI.prepStrs, std1Q_XYI.effectStrs germs = std1Q_XYI.germs maxLengths = [1, 2] target_model = std1Q_XYI.target_model("full TP", sim_type="map") mdl_datagen = target_model.depolarize(op_noise=0.01, spam_noise=0.001) edesign = pygsti.protocols.StandardGSTDesign(target_model.create_processor_spec(), prep_fiducials, meas_fiducials, germs, maxLengths) # *sparse*, time-independent data ds = pygsti.data.simulate_data(mdl_datagen, edesign.all_circuits_needing_data, num_samples=10, sample_error="binomial", seed=1234, times=[0], record_zero_counts=False) data = pygsti.protocols.ProtocolData(edesign, ds) target_model.sim = pygsti.forwardsims.MapForwardSimulator(max_cache_size=0) # No caching allowed for time-dependent calcs self.assertEqual(ds.degrees_of_freedom(aggregate_times=False), 126) builders = pygsti.protocols.GSTObjFnBuilders([pygsti.objectivefns.TimeDependentPoissonPicLogLFunction.builder()], []) gst = pygsti.protocols.GateSetTomography(target_model, gaugeopt_suite=None, objfn_builders=builders) results = gst.run(data) # Normal GST used as a check - should get same answer since data is time-independent results2 = pygsti.run_long_sequence_gst(ds, target_model, prep_fiducials, meas_fiducials, germs, maxLengths, verbosity=3, advanced_options={'starting_point': 'target', 'always_perform_mle': True, 'only_perform_mle': True}, gauge_opt_params=False)
def testRepLib_map(self): #Just test a Model with a "map" simtype to exercise the replib mdl = std.target_model() mdl.set_simtype("map") probs = mdl.probs(('Gx', 'Gx')) self.assertAlmostEqual(probs['0'], 0.0) self.assertAlmostEqual(probs['1'], 1.0) probs2 = mdl.bulk_probs([('Gx', ), ('Gx', 'Gx'), ('Gx', 'Gx', 'Gy')]) self.assertAlmostEqual(probs2[('Gx', )]['0'], 0.5) self.assertAlmostEqual(probs2[('Gx', )]['1'], 0.5) self.assertAlmostEqual(probs2[('Gx', 'Gx')]['0'], 0.0) self.assertAlmostEqual(probs2[('Gx', 'Gx')]['1'], 1.0) self.assertAlmostEqual(probs2[('Gx', 'Gx', 'Gy')]['0'], 0.5) self.assertAlmostEqual(probs2[('Gx', 'Gx', 'Gy')]['1'], 0.5) #LATER: save & check outputs of dprobs dprobs = mdl.bulk_dprobs([('Gx', ), ('Gx', 'Gx'), ('Gx', 'Gx', 'Gy')]) #RUN TO SAVE outputs if regenerate_references(): pickle.dump(dprobs, open(compare_files + "/repLib_dprobs.pkl", 'wb')) compare = pickle.load(open(compare_files + "/repLib_dprobs.pkl", 'rb')) for opstr in dprobs: for outcomeLbl in dprobs[opstr]: self.assertArraysAlmostEqual(dprobs[opstr][outcomeLbl], compare[opstr][outcomeLbl])
def test_chi2(self): # TODO rather than faking expensive calls this should really use a simpler dataset with mock.patch( 'pygsti.forwardsims.matrixforwardsim.MatrixForwardSimulator._compute_hproduct_cache' ) as mock_hproduct_cache: mock_hproduct_cache.return_value = np.zeros((868, 60, 60, 4, 4)) chi2fns.chi2(std.target_model(), self.dataset) chi2fns.chi2fn_2outcome(n=100, p=0.5, f=0.6) chi2fns.chi2fn_2outcome_wfreqs(n=100, p=0.5, f=0.6) chi2fns.chi2fn(n=100, p=0.5, f=0.6) chi2fns.chi2fn_wfreqs(n=100, p=0.5, f=0.6) chi2fns.chi2(std.target_model(), self.dataset, mem_limit=1000000000)
def test_inline_template(self): #Generate some results (quickly) mdl_tgt = std.target_model() #Mimic factory report creation to test "inline" rendering of switchboards, tables, and figures: qtys = {} qtys['title'] = "Test Inline Report" qtys['date'] = "THE DATE" qtys['pdfinfo'] = "PDFINFO" ws = pygsti.report.Workspace() printer = pygsti.obj.VerbosityPrinter(1) qtys['targetGatesBoxTable'] = ws.GatesTable(mdl_tgt, display_as="boxes") # 3) populate template file => report file linkto = () if bLatex: linkto = ('tex', 'pdf') + linkto #Note: can't render as 'tex' without matplotlib b/c of figs if bPandas: linkto = ('pkl',) + linkto toggles = {'CompareDatasets': False, 'ShowScaling': False, 'CombineRobust': True } if os.path.exists(temp_files + "/inline_report.html.files"): shutil.rmtree(temp_files + "/inline_report.html.files") #clear figures directory pygsti.report.merge_helpers.merge_jinja_template(qtys, temp_files + "/inline_report.html", templateDir=compare_files, templateName="report_dashboard_template.html", auto_open=False, precision=None, link_to=linkto, connected=False, toggles=toggles, renderMath=True, resizable=True, autosize='none', verbosity=printer)
def setUp(self): #Add an instrument to the standard target model self.target_model = std.target_model() E = self.target_model.povms['Mdefault']['0'] Erem = self.target_model.povms['Mdefault']['1'] Gmz_plus = np.dot(E, E.T) Gmz_minus = np.dot(Erem, Erem.T) self.target_model.instruments['Iz'] = pygsti.obj.Instrument({ 'plus': Gmz_plus, 'minus': Gmz_minus }) self.povm_ident = self.target_model.povms['Mdefault'][ '0'] + self.target_model.povms['Mdefault']['1'] self.mdl_target_wTP = self.target_model.copy() self.mdl_target_wTP.instruments['IzTP'] = pygsti.obj.TPInstrument({ 'plus': Gmz_plus, 'minus': Gmz_minus }) super(InstrumentTestCase, self).setUp()
def test_simulate_circuitlabels(self): from pygsti.modelpacks.legacy import std1Q_XYI pygsti.obj.Circuit.default_expand_subcircuits = False # so mult/exponentiation => CircuitLabels try: Gi = pygsti.obj.Circuit(None, stringrep='Gi', editable=True) Gy = pygsti.obj.Circuit(None, stringrep='Gy', editable=True) c2 = Gy * 2 #print(c2.tup) c3 = Gi + c2 c2.done_editing() c3.done_editing() Gi.done_editing() Gy.done_editing() tgt = std1Q_XYI.target_model() for N, zeroProb in zip((1, 2, 10, 100, 10000), (0.5, 0, 0, 1, 1)): p1 = tgt.probs(('Gi', ) + ('Gy', ) * N) p2 = tgt.probs(Gi + Gy * N) self.assertAlmostEqual(p1['0'], zeroProb) self.assertAlmostEqual(p2['0'], zeroProb) finally: pygsti.obj.Circuit.default_expand_subcircuits = True
def test_bootstrap(self): """Test bootstrap model generation""" ds = pygsti.objects.DataSet(fileToLoadFrom=compare_files + "/drivers.dataset") tp_target = std.target_model() tp_target.set_all_parameterizations("TP") mdl = pygsti.do_lgst(ds, std.fiducials, std.fiducials, targetModel=tp_target, svdTruncateTo=4, verbosity=0) default_maxLens = [0] + [2**k for k in range(10)] circuits = pygsti.construction.make_lsgst_experiment_list( self.opLabels, self.fiducials, self.fiducials, self.germs, default_maxLens, fidPairs=None, truncScheme="whole germ powers") ds_defaultMaxLens = pygsti.construction.generate_fake_data( mdl, circuits, nSamples=10000, sampleError='round') bootgs_p_defaultMaxLens = \ pygsti.drivers.make_bootstrap_models( 2, ds_defaultMaxLens, 'parametric', std.fiducials, std.fiducials, std.germs, None, inputModel=mdl, returnData=False) #test when maxLengths == None
def test_longSequenceGST_GLND(self): #General Lindbladian parameterization (allowed to be non-CPTP) ds = pygsti.objects.DataSet(fileToLoadFrom=compare_files + "/drivers.dataset") target_model = std.target_model() #No set_all_parameterizations option for this one, since it probably isn't so useful for lbl, gate in target_model.operations.items(): target_model.operations[lbl] = pygsti.objects.operation.convert( gate, "GLND", "gm") target_model.default_gauge_group = pygsti.objects.UnitaryGaugeGroup( target_model.dim, "gm") #Lindblad gates only know how to do unitary transforms currently, even though # in the non-cptp case it they should be able to transform generally. maxLens = self.maxLens result = self.runSilent(pygsti.do_long_sequence_gst, ds, target_model, std.fiducials, std.fiducials, std.germs, maxLens) #create a report... pygsti.report.create_standard_report(result, temp_files + "/full_report_SGates", "SGates report", verbosity=2)
def test_stdgst_prunedpath(self): # Using term-based (path integral) calculation with path pruning # This performs a map-based unitary evolution along each path. target_model = std.target_model() target_model.set_all_parameterizations("H+S terms") target_model.set_simtype('termgap', max_order=3, desired_perr=0.01, allowed_perr=0.1, max_paths_per_outcome=1000, perr_heuristic='scaled', max_term_stages=5) results = pygsti.do_long_sequence_gst(self.ds, target_model, std.prepStrs, std.effectStrs, std.germs, self.maxLengths, verbosity=3) #RUN BELOW LINES TO SAVE GATESET (SAVE) if regenerate_references(): pygsti.io.json.dump( results.estimates['default'].models['go0'], open(compare_files + "/test1Qcalc_std_prunedpath.model", 'w')) print("MISFIT nSigma = ", results.estimates['default'].misfit_sigma()) self.assertAlmostEqual(results.estimates['default'].misfit_sigma(), 3, delta=1.0)