def test_project_model(self): projectionTypes = ('H', 'S', 'H+S', 'LND', 'LNDF') target_model = std2Q_XXYYII.target_model() mdl = target_model.depolarize(op_noise=0.01) for genType in ("logG-logT", "logTiG", "logGTi"): proj_model, Np_dict = optools.project_model( mdl, target_model, projectionTypes, genType) with self.assertRaises(ValueError): mdl_target_gm = std2Q_XXYYII.target_model() mdl_target_gm.basis = pygsti.obj.Basis.cast("gm", 16) optools.project_model(mdl, mdl_target_gm, projectionTypes, genType) # basis mismatch
def test_logGTi_model_projection(self): gen_type = 'logGTi' proj_model, Np_dict = ot.project_model(self.model, self.target_model, self.projectionTypes, gen_type) # Project a second time and ensure models don't change for pm1, ptype in zip(proj_model, self.projectionTypes): proj2, _ = ot.project_model(pm1, self.target_model, [ptype], gen_type, logG_weight=0) pm2 = proj2[0] for pm1_op, pm2_op in zip(pm1.operations.values(), pm2.operations.values()): self.assertArraysAlmostEqual(pm1_op, pm2_op)
def test_log_diff_model_projection(self): self.skipTest( "project_model for logG-logT is known to be inconsistent in testing (Gxx,Gxy,Gyx,Gyy gates). Skip tests until it gets fixed." ) basis = self.target_model.basis gen_type = 'logG-logT' proj_model, Np_dict = ot.project_model(self.model, self.target_model, self.projectionTypes, gen_type, logG_weight=0) # Project a second time and ensure models don't change for pm1, ptype in zip(proj_model, self.projectionTypes): proj2, _ = ot.project_model(pm1, self.target_model, [ptype], gen_type, logG_weight=0) pm2 = proj2[0] for pm1_op, pm2_op in zip(pm1.operations.values(), pm2.operations.values()): self.assertArraysAlmostEqual(pm1_op, pm2_op)
def test_raises_on_basis_mismatch(self): with self.assertRaises(ValueError): mdl_target_gm = std2Q_XXYYII.target_model() mdl_target_gm.basis = Basis.cast("gm", 16) ot.project_model(self.model, mdl_target_gm, self.projectionTypes, 'logGti') # basis mismatch
def test_log_diff_model_projection(self): proj_model, Np_dict = ot.project_model(self.model, self.target_model, self.projectionTypes, 'logG-logT')