I am trying to make a function like this in Qiskit:
def some_function(qc: QuantumCircuit):
# Add a register to qc
qc.add_register(size, name)
# Do some computation
# Remove the register from qc
The first two tasks of adding a register and doing some computation on the qubits is okay. For the last part, i.e., removing the register, I couldn't find any resources on the web. The documentation for QuantumCircuit didn't list anything as such to remove a register.
This discussion does give some idea of how to remove idle wires from a quantum circuit, but my problem is to remove only the specific qubits in the register that I am adding, not all the idle ones. Moreover, the register information is lost by following what the suggested answer gives, which I do not want.
This discussion gives the equivalent solution for Quantum Gates, not registers.
Is there a way to remove a register from a quantum circuit by name of register? Any help would definitely be appreciated!