dwavesystems / dwave-gate

dwave-gate is a software package for constructing, modifying and running quantum circuits on the provided state-vector simulator.
Apache License 2.0
12 stars 7 forks source link

Consider returning the `Qubit` object from `Circuit.add_qubit()` #14

Open arcondello opened 1 year ago

arcondello commented 1 year ago

Currently there is not an easy way to retrieve a qubit added by label. E.g.

c = Circuit()
c.add_qubit("q1")

it would be nice to be able to do

q2 = c.add_qubit("q2")
thisac commented 1 year ago

Actually, Circuit.add_qubit only accept Qubit objects, not labels. You would thus have to write:

c = Circuit()
qubit = Qubit("q1")
c.add_qubit(qubit)

The only case where you don't have access to the qubit directly is if you simply add a qubit without creating it first:

c = Circuit()
c.add_qubit()

in which case it's not obvious how to get hold of the newly added qubit (it will always be placed at the end of the originally created register, unless specified), although it's similar to adding qubits when initializing the circuit:

c = Circuit(3)

or when adding a new register:

c = Circuit(2)
c.add_qregister(3)