예제 #1
0
    def test_fix_qubits_large_fifth_qubit_forbidden(self):
        """Tests if qubits are fixed correctly for an operator on a large number of qubits."""
        operator = (Z ^ I ^ I ^ I ^ I ^ Z ^ Z) + (I ^ Z ^ Z ^ Z ^ I ^ I ^ I)
        fixed = _fix_qubits(operator)

        expected = -(I ^ I ^ Z ^ I ^ I ^ I ^ I) - (Z ^ I ^ I ^ I ^ I ^ I ^ I)
        self.assertEqual(fixed, expected)
예제 #2
0
    def test_fix_qubits_large_fifth_qubit_allowed(self):
        """Tests if qubits are fixed correctly for an operator on a large number of qubits."""
        operator = (Z ^ I ^ I ^ I ^ I ^ Z ^ Z) + (I ^ Z ^ Z ^ Z ^ I ^ I ^ I)
        has_side_chain_second_bead = True
        fixed = _fix_qubits(operator, has_side_chain_second_bead)

        expected = (I ^ Z ^ Z ^ I ^ I ^ I ^ I) - (Z ^ I ^ I ^ I ^ I ^ I ^ I)
        self.assertEqual(fixed, expected)
예제 #3
0
 def test_fix_qubits_pauli_op(self):
     """Tests if qubits are fixed correctly for an operator which is a PauliOp."""
     operator = Z ^ I ^ I ^ I ^ I ^ Z ^ Z
     fixed = _fix_qubits(operator)
     expected = Z ^ I ^ I ^ I ^ I ^ I ^ I
     self.assertEqual(fixed, expected)
예제 #4
0
 def test_fix_qubits_small_2(self):
     """Tests if qubits are fixed correctly for an operator on a small number of qubits."""
     operator = (Z ^ Z) + (I ^ I)
     fixed = _fix_qubits(operator)
     expected = PauliSumOp.from_list([("II", 0)])
     self.assertEqual(fixed, expected)