Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
arcondello opened this issue Jan 3, 2023 · 1 comment
Open

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

arcondello opened this issue Jan 3, 2023 · 1 comment

Comments

@arcondello
Copy link
Member

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
Copy link
Collaborator

thisac commented Feb 3, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants