def test_equality_sub(self): a, b = Qbit("a"), Qbit("b") exp = 1-a-b expected_exp = AddList([Mul(a, -1), Num(1.0), Mul(b, -1)]) self.assertTrue(exp == expected_exp) self.assertTrue(exp - 0.0 == expected_exp)
def test_equality_of_express(self): a, b = Qbit("a"), Qbit("b") exp = a * b + 2 * a - 1 expected_exp = AddList([Mul(a, b), Num(-1.0), Mul(a, 2)]) self.assertTrue(exp == expected_exp)
def test_equality_sub2(self): a, b = Qbit("a"), Qbit("b") exp = a - b - 1 expected_exp = AddList([a, Num(-1.0), Mul(b, -1)]) self.assertTrue(exp == expected_exp)
def test_equality_of_express_with_param(self): a, b, p = Qbit("a"), Qbit("b"), Param("p") exp = a + b - 1 + a * p expected_exp = AddList([a, Num(-1.0), b, Mul(p, a)]) self.assertTrue(exp == expected_exp)
def test_equality_of_express_with_placeholder(self): a, b, p = Binary("a"), Binary("b"), Placeholder("p") exp = a + b - 1 + a * p expected_exp = AddList([a, Num(-1.0), b, Mul(p, a)]) self.assertTrue(exp == expected_exp)