Skip to content

Fix num_qubits() and num_clbits() methods#122

Merged
doichanj merged 1 commit into
Qiskit:mainfrom
mtreinish:remove-target-from-bit-count-methods
Oct 14, 2025
Merged

Fix num_qubits() and num_clbits() methods#122
doichanj merged 1 commit into
Qiskit:mainfrom
mtreinish:remove-target-from-bit-count-methods

Conversation

@mtreinish

Copy link
Copy Markdown
Member

Summary

The num bits methods were incorrectly querying the target stored with the circuit, when present, for the number of bits instead of the actual circuit attributes. This commit fixes this issue so the circuit bit counts are correctly returned.

There is a larger question around why the circuit is locally storing the bit counts instead of just querying the inner qiskit circuit object. But for just fixing this issue I kept the change minimal rather than removing the protected attribute. We can do that in a follow up if needed.

Details and comments

The num bits methods were incorrectly querying the target stored with
the circuit, when present, for the number of bits instead of the actual
circuit attributes. This commit fixes this issue so the circuit bit
counts are correctly returned.

There is a larger question around why the circuit is locally storing the
bit counts instead of just querying the inner qiskit circuit object. But
for just fixing this issue I kept the change minimal rather than
removing the protected attribute. We can do that in a follow up if
needed.
@doichanj doichanj merged commit ffb57d9 into Qiskit:main Oct 14, 2025
6 checks passed
@mtreinish mtreinish deleted the remove-target-from-bit-count-methods branch October 14, 2025 09:57
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

Successfully merging this pull request may close these issues.

2 participants