Skip to content

Commit ffb57d9

Browse files
authored
Fix num_qubits() and num_clbits() methods (#122)
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.
1 parent b386265 commit ffb57d9

1 file changed

Lines changed: 0 additions & 8 deletions

File tree

src/circuit/quantumcircuit_def.hpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,13 @@ class QuantumCircuit
104104
/// @return number of qubits
105105
uint_t num_qubits(void) const
106106
{
107-
if (target_)
108-
{
109-
return target_->num_qubits();
110-
}
111107
return num_qubits_;
112108
}
113109

114110
/// @brief Return number of classical bits
115111
/// @return number of classical bits
116112
uint_t num_clbits(void) const
117113
{
118-
if (target_)
119-
{
120-
return target_->num_qubits();
121-
}
122114
return num_clbits_;
123115
}
124116

0 commit comments

Comments
 (0)