-
Notifications
You must be signed in to change notification settings - Fork 99
Extracting Qubit Indices #1587
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
Extracting Qubit Indices #1587
Conversation
Thanks for contributing to Qiskit documentation! Before your PR can be merged, it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. Thanks! 🙌 |
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
" # Method 2: Using qubits.index to get the index\n", | ||
" qarg_indices_index = [qc.qubits.index(qarg) for qarg in qargs]\n", | ||
" print(\"qargs indices (index):\", qarg_indices_index)\n", | ||
" print(\"\\n\")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not recommend this, it will have significant performance overhead which scales quadratically with the number of qubit it's almost never the right thing to do. The find_bit()
pattern was added specifically to have a constant time lookup for this and should be the only thing we recommend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mtreinish what do you suggest should we add only the find_bit() pattern
@mtreinish for some reason I am not able to make changes directly into the source code of the ipynb file do you want me to make a notebook for this |
I'm closing this PR as this issue is already being worked on by another contributor. |
Hi Frank thanks but I have not heard back from you on the blogpost yet for our project can I get an update |
the issue brought up by the users on Slack regarding how to retrieve the index of a qubit within a QuantumCircuit object. The original documentation lacked clarity on this point, which led to confusion among users. The updated version explains how to extract the index of a qubit from a Qubit object using both QuantumCircuit.find_bit() and QuantumCircuit.qubits.index(), ensuring that users can easily understand how to manage qubits and registers in their circuits.
fixes #1469