def test_resize(self):
        """Test resizing the Random Pauli circuit preserves the gates."""
        circuit = PauliTwoDesign(1)
        top_gates = [op.name for op, _, _ in circuit.data]

        circuit.num_qubits = 3
        with self.subTest('assert existing gates remain'):
            new_top_gates = []
            for op, qargs, _ in circuit:
                if qargs == [circuit.qubits[0]]:  # if top qubit
                    new_top_gates.append(op.name)

            self.assertEqual(top_gates, new_top_gates)
    def test_resize(self):
        """Test resizing the Random Pauli circuit preserves the gates."""
        circuit = PauliTwoDesign(1)
        top_gates = [
            instruction.operation.name
            for instruction in circuit.decompose().data
        ]

        circuit.num_qubits = 3
        decomposed = circuit.decompose()
        with self.subTest("assert existing gates remain"):
            new_top_gates = []
            for instruction in decomposed:
                if instruction.qubits == (
                        decomposed.qubits[0], ):  # if top qubit
                    new_top_gates.append(instruction.operation.name)

            self.assertEqual(top_gates, new_top_gates)