예제 #1
0
    def test_helpers(self):
        self.assertTrue(rptbl._nullFn("Any arguments") is None)

        self.assertAlmostEqual(rptbl._projectToValidProb(-0.1), 0.0)
        self.assertAlmostEqual(rptbl._projectToValidProb(1.1), 1.0)
        self.assertAlmostEqual(rptbl._projectToValidProb(0.5), 0.5)

        nan_qty = rptbl.evaluate(None)  # none function -> nan qty
        self.assertTrue(np.isnan(nan_qty.value))

        #deprecated:
        rptbl.decomposition(std.target_model().operations['Gx'])
        rptbl.decomposition(np.zeros((4, 4), 'd'))
예제 #2
0
    def test_functions(self):

        gs1 = std.target_model().depolarize(op_noise=0.1, spam_noise=0.05)
        gs2 = std.target_model()
        gl = "Gx"  # operation label
        opstr = pygsti.obj.Circuit(('Gx', 'Gx'))
        syntheticIdles = pygsti.construction.circuit_list([('Gx', ) * 4,
                                                           ('Gy', ) * 4])

        gatesetfn_factories = (  # model, oplabel
            rptbl.Choi_matrix,
            rptbl.Choi_evals,
            rptbl.Choi_trace,
            rptbl.Gate_eigenvalues,  #GAP
            rptbl.Upper_bound_fidelity,
            rptbl.Closest_ujmx,
            rptbl.Maximum_fidelity,
            rptbl.Maximum_trace_dist,
        )
        for gsf_factory in gatesetfn_factories:
            gsf = gsf_factory(gs1, gl)
            rptbl.evaluate(gsf)

        gatesetfn_factories = (  # model, circuit
            rptbl.Circuit_eigenvalues, )
        for gsf_factory in gatesetfn_factories:
            gsf = gsf_factory(gs1, opstr)
            rptbl.evaluate(gsf)

        gatesetfn_factories = (  # modelA, modelB, circuit
            rptbl.Rel_circuit_eigenvalues,
            rptbl.Circuit_fro_diff,
            rptbl.Circuit_entanglement_infidelity,
            rptbl.Circuit_avg_gate_infidelity,
            rptbl.Circuit_jt_diff,
            rptbl.Circuit_half_diamond_norm,
            rptbl.Circuit_nonunitary_entanglement_infidelity,
            rptbl.Circuit_nonunitary_avg_gate_infidelity,
            rptbl.Circuit_eigenvalue_entanglement_infidelity,
            rptbl.Circuit_eigenvalue_avg_gate_infidelity,
            rptbl.Circuit_eigenvalue_nonunitary_entanglement_infidelity,
            rptbl.Circuit_eigenvalue_nonunitary_avg_gate_infidelity,
            rptbl.Circuit_eigenvalue_diamondnorm,
            rptbl.Circuit_eigenvalue_nonunitary_diamondnorm,
        )
        for gsf_factory in gatesetfn_factories:
            gsf = gsf_factory(gs1, gs2, opstr)
            rptbl.evaluate(gsf)

        gatesetfn_factories = (  # modelA, modelB, povmlbl
            rptbl.POVM_entanglement_infidelity,
            rptbl.POVM_jt_diff,
            rptbl.POVM_half_diamond_norm,
        )
        for gsf_factory in gatesetfn_factories:
            gsf = gsf_factory(gs1, gs2, "Mdefault")
            rptbl.evaluate(gsf)

        gatesetfn_factories = (  # model
            rptbl.Spam_dotprods,
            rptbl.Angles_btwn_rotn_axes,
        )
        for gsf_factory in gatesetfn_factories:
            gsf = gsf_factory(gs1)
            rptbl.evaluate(gsf)

        gatesetfn_factories = (  # modelA, modelB, gatelbl
            rptbl.Entanglement_fidelity,
            rptbl.Entanglement_infidelity,
            rptbl.Closest_unitary_fidelity,
            rptbl.Fro_diff,
            rptbl.Jt_diff,
            rptbl.Half_diamond_norm,
            rptbl.Nonunitary_entanglement_infidelity,
            rptbl.Nonunitary_avg_gate_infidelity,
            rptbl.Eigenvalue_nonunitary_entanglement_infidelity,
            rptbl.Eigenvalue_nonunitary_avg_gate_infidelity,
            rptbl.Eigenvalue_entanglement_infidelity,
            rptbl.Eigenvalue_avg_gate_infidelity,
            rptbl.Eigenvalue_diamondnorm,
            rptbl.Eigenvalue_nonunitary_diamondnorm,
            rptbl.Avg_gate_infidelity,
            rptbl.Model_model_angles_btwn_axes,
            rptbl.Rel_eigvals,
            rptbl.Rel_logTiG_eigvals,
            rptbl.Rel_logGTi_eigvals,
            rptbl.Rel_logGmlogT_eigvals,
            rptbl.Rel_gate_eigenvalues,
            rptbl.LogTiG_and_projections,
            rptbl.LogGTi_and_projections,
            rptbl.LogGmlogT_and_projections,
        )
        for gsf_factory in gatesetfn_factories:
            gsf = gsf_factory(gs1, gs2, gl)
            rptbl.evaluate(gsf)

        gatesetfn_factories = (  # modelA, modelB, syntheticIdleStrs
            rptbl.Robust_LogGTi_and_projections, )
        for gsf_factory in gatesetfn_factories:
            gsf = gsf_factory(gs1, gs2, syntheticIdles)
            rptbl.evaluate(gsf)

        gatesetfn_factories = (  # modelA, modelB
            rptbl.General_decomposition,
            rptbl.Average_gateset_infidelity,
            rptbl.Predicted_rb_number,
        )
        for gsf_factory in gatesetfn_factories:
            gsf = gsf_factory(gs1, gs2)
            rptbl.evaluate(gsf)

        gatesetfn_factories = (  # model1, model2, label, typ
            rptbl.Vec_fidelity,
            rptbl.Vec_infidelity,
            rptbl.Vec_tr_diff,
        )
        for gsf_factory in gatesetfn_factories:
            gsf = gsf_factory(gs1, gs2, "rho0", "prep")
            rptbl.evaluate(gsf)
            gsf = gsf_factory(gs1, gs2, "Mdefault:0", "effect")
            rptbl.evaluate(gsf)

        gatesetfn_factories = (  # model, label, typ
            rptbl.Vec_as_stdmx,
            rptbl.Vec_as_stdmx_eigenvalues,
        )
        for gsf_factory in gatesetfn_factories:
            gsf = gsf_factory(gs1, "rho0", "prep")
            rptbl.evaluate(gsf)
            gsf = gsf_factory(gs1, "Mdefault:0", "effect")
            rptbl.evaluate(gsf)