Getting more information about a circuit
In the previous section, we used the QuantumCircuit
class’s count_ops
function to find out whether Alice applies an X gate and whether the circuit has an even or odd number of Hadamard gates. Sometimes, you need to discover more details about an existing circuit. For cases of this kind, you can use the QuantumCircuit
class’s data
attribute. A circuit’s data
attribute contains enough information to recreate the circuit in its entirety. Take, for example, the circuit shown in Figure 5.21:
Figure 5.21 – The smallest circuit returned by any call to make_new_circuit
If you print this circuit’s data
attribute, and you add your own line breaks, you will see the following information:
[ CircuitInstruction( operation=Instruction( name='swap', num_qubits=2, num_clbits=0, params=[] ...