def test_reps(self): """Test reps and order params in Trotterization""" reps = 7 trotter = Trotter(reps=reps) self.assertEqual(trotter.reps, reps) order = 5 suzuki = Suzuki(reps=reps, order=order) self.assertEqual(suzuki.reps, reps) self.assertEqual(suzuki.order, order) qdrift = QDrift(reps=reps) self.assertEqual(qdrift.reps, reps)
def test_qdrift(self): """ QDrift test """ op = (2 * Z ^ Z) + (3 * X ^ X) - (4 * Y ^ Y) + (.5 * Z ^ I) trotterization = QDrift().convert(op) self.assertGreater(len(trotterization.oplist), 150) last_coeff = None # Check that all types are correct and all coefficients are equals for op in trotterization.oplist: self.assertIsInstance(op, (EvolvedOp, CircuitOp)) if isinstance(op, EvolvedOp): if last_coeff: self.assertEqual(op.primitive.coeff, last_coeff) else: last_coeff = op.primitive.coeff