Exemplo n.º 1
0
 def test_init_multiple_digits(self):
     """Test __init__ for sparse label with multiple digits"""
     actual = SpinOp([("X_10^20", 1 + 2j), ("X_12^34", 56)],
                     Fraction(5, 2),
                     register_length=13)
     desired = [("X_10^20", 1 + 2j), ("X_12^34", 56)]
     self.assertListEqual(actual.to_list(), desired)
Exemplo n.º 2
0
 def test_init_label(self, label, pre_processing):
     """Test __init__"""
     spin = SpinOp(pre_processing(label), register_length=len(label) // 3)
     expected_label = " ".join(l for l in label.split() if l[0] != "I")
     if not expected_label:
         expected_label = f"I_{len(label) // 3 - 1}"
     self.assertListEqual(spin.to_list(), [(expected_label, 1)])
     self.assertSpinEqual(eval(repr(spin)), spin)  # pylint: disable=eval-used
Exemplo n.º 3
0
 def test_init_len2_label(self, label):
     """Test __init__"""
     spin = SpinOp(f"{label[1]}_1 {label[0]}_0")
     self.assertListEqual(spin.to_list(),
                          [(f"{label[1]}_1 {label[0]}_0", 1)])