fix: remove_idle_qubits(in_place=False) updating qubit count on the wrong module#336
fix: remove_idle_qubits(in_place=False) updating qubit count on the wrong module#336ryanhill1 wants to merge 1 commit into
Conversation
…e original module remove_idle_qubits routed every mutation through qasm_module (self or a deepcopy depending on in_place) except the qubit-count update, which used self. With in_place=False the original module's count was decremented and the returned copy kept the stale pre-removal count. Fixes #334
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary of changes
Closes #334.
remove_idle_qubitsroutes every mutation throughqasm_module— which isselfor a deepcopy depending onin_place— except the qubit-count update at the end of the register loop, which usedself. Within_place=Falsethe original module'snum_qubitswas decremented and the returned copy kept the stale pre-removal count:The copy's AST was already correct (declaration size, operand indices,
dumps()output); only the counters were swapped. This also switches thesizelookup two lines above fromselftoqasm_modulefor consistency — harmless today since the registers are identical at that point, but it keeps the method reading from one object.Regression test asserts both sides: the returned copy reports the reduced count and dumps the collapsed register, and the original module is left untouched.
🤖 Generated with Claude Code