support different number of alphas and betas
@@ -1107,9 +1107,17 @@ class Operator(object):
if self._paulis is None or self._paulis == []:
return self
+ if isinstance(m, list):
+ num_alpha = m[0]
+ num_beta = m[1]
+ else:
+ num_alpha = m // 2
+ num_beta = m // 2
+
operator_out = Operator(paulis=[])
- par_1 = 1 if m % 2 == 0 else -1
- par_2 = 1 if m % 4 == 0 else -1
+
+ par_1 = 1 if (num_alpha + num_beta) % 2 == 0 else -1
+ par_2 = 1 if num_alpha % 2 == 0 else -1
n = self.num_qubits
last_idx = n - 1
