def test_is_equal(self): """test 'is_equal' """ qc_L = QCirc().h(0).cx(0, 1).rx(1, phase=0.2) qc_R = QCirc().crx(0, 1, phase=0.3).measure(qid=[0, 1, 2], cid=[0, 1, 2]) qc_L_clone = qc_L.clone() ans = (qc_L == qc_R) self.assertEqual(qc_L == qc_R, False) self.assertEqual(qc_R != qc_L, True) self.assertEqual(qc_L == qc_L_clone, True) self.assertEqual(qc_L != qc_L_clone, False)
def test_merge_incremental(self): """test 'merge' (incremental) """ qc_1 = QCirc().h(0).cx(0, 1).rx(1, phase=0.2) qc_2 = QCirc().cry(0, 1, phase=0.3).measure(qid=[0, 1, 2], cid=[0, 1, 2]) qc_3 = QCirc().x(0).z(5) qc_expect = QCirc().h(0).cx(0, 1).rx(1, phase=0.2).cry( 0, 1, phase=0.3).measure(qid=[0, 1, 2], cid=[0, 1, 2]).x(0).z(5) qc_actual = qc_1.clone() qc_actual += qc_2 qc_actual += qc_3 self.assertEqual(qc_actual == qc_expect, True)